api config mongo - wwwsolutions/nestjs-starter-kit GitHub Wiki

TODO:

Nx NestJs Starter - REST API

Install Mongoose

npm i @nestjs/mongoose@^9.0.1 mongoose@^6.0.12

Generate

// generate config lib
nx generate @nrwl/nest:library --name=swagger --directory=api/config --buildable --standaloneConfig --strict --tags=type:config --no-interactive

EDIT FILES

// libs/api/integration/rest-mongoose/src/lib/configure-api-integration-rest-mongoose.ts

  /******************************************************
   *            ENABLE SWAGGER                          *
   ******************************************************/
   configureSwagger(app, appConfig);

CREATE FUNCTION configureSwagger

Configure Swagger plugin in project.json

You do not have manually map/decorate dtos anymore. plugin does it for you

// apps/api/project.json#targets.build.options

// add
    "tsPlugins": [
      {
        "name": "@nestjs/swagger/plugin",
        "options": {
          "dtoFileNameSuffix": [".dto.ts", ".model.ts"]
        }
      }
    ]

ADD ENV VAR

SWAGGER_UI_DIR='docs'

CREATE swagger.configuration.ts

REGISTER configuration

ADD configuration validation

⚠️ **GitHub.com Fallback** ⚠️