Check the contributing manual
- docker
- secrets service
- logs service
- error handler
- libs structure
- Dependency Inversion Pattern
- Anti Corruption Layer Pattern
- Adapter Pattern
- Generic Repository Pattern
- swaggger documentation
- mongodb
- mongoose
- multiples databases
- tests
- unit
- e2e
- install monorepo dependencies
$ yarn monorepo:install
- install project dependencies
$ yarn workspace <workspaceName> install
- install lib on project
$ yarn workspace <workspaceName> add <libName>
- @app/main.api
- @app/other.api
- @tools/eslint.config
- @libs/utils
- @libs/modules
- @libs/core
-
local
$ yarn start:main $ yarn start:other
-
dev/hml/prd environment
$ docker-compose up --build
-
unit
# run monorepo tests $ yarn test
# Run project tests $ yarn test main.api $ yarn test other.api $ yarn test libs
-
e2e
$ yarn test:e2e
-
coverage
$ yarn test:coverage
- Run monorepo lint
$ yarn lint
- Run project lint
$ yarn workspace <workspaceName> lint
- Run project build
$ yarn build <workspaceName>
-
logs
import { ILoggerService } from 'libs/modules'; export class Exmeple { constructor(private readonly loggerService: ILoggerService) {} async exemple(): void { this.loggerService.log('message', 'messageContext'); this.loggerService.error('error', 500, `${Exmeple.name}/${exemple.name}`); } }
-
Secrets
import { ICommonSecrets } from 'libs/modules'; export class Exmeple { constructor(private readonly secretService: ICommonSecrets) {} async exemple(): void { this.secretService.PORT; } }
-
Error exception
import { ApiException } from 'libs/utils'; export class Exmeple { async exemple(): void { throw new ApiException('Error', HttpStatus.INTERNAL_SERVER_ERROR) } }
-
Http
import { IHttpService } from 'libs/modules'; export class Example { constructor( private readonly httpService: IHttpService, ) {} async exemple(): Promise<string> { const { data } = await this.httpService.http.get('http://url'); return data.message; } }
- clone
git clone https://github.com/mikemajesty/other-api.git
-- Example App
.
├── apps
│ ├── main-api
│ │ ├── Dockerfile
│ │ ├── jest.config.js
│ │ ├── package.json
│ │ ├── src
│ │ │ ├── main.ts
│ │ │ └── modules
│ │ │ ├── health
│ │ │ │ ├── adapter.ts
│ │ │ │ ├── controller.ts
│ │ │ │ ├── module.ts
│ │ │ │ ├── service.ts
│ │ │ │ ├── swagger.ts
│ │ │ │ └── __tests__
│ │ │ │ ├── controller.e2e.spec.ts
│ │ │ │ ├── module.spec.ts
│ │ │ │ └── service.spec.ts
│ │ │ ├── module.ts
│ │ │ └── __tests__
│ │ │ └── module.spec.ts
│ │ ├── tsconfig.build.json
│ │ └── tsconfig.json
│ └── other-api
│ ├── Dockerfile
│ ├── jest.config.js
│ ├── package.json
│ ├── src
│ │ ├── main.ts
│ │ └── modules
│ │ ├── health
│ │ │ ├── adapter.ts
│ │ │ ├── controller.ts
│ │ │ ├── module.ts
│ │ │ ├── service.ts
│ │ │ ├── swagger.ts
│ │ │ └── __tests__
│ │ │ ├── controller.e2e.spec.ts
│ │ │ ├── module.spec.ts
│ │ │ └── service.spec.ts
│ │ ├── module.ts
│ │ └── __tests__
│ │ └── module.spec.ts
│ ├── tsconfig.build.json
│ └── tsconfig.json
├── CHANGELOG.md
├── commitlint.config.ts
├── CONTRIBUTING.md
├── devops
│ └── tag-create.sh
├── docker-compose.yml
├── jest.config.e2e.ts
├── jest.config.ts
├── libs
│ ├── core
│ │ ├── index.ts
│ │ ├── jest.config.js
│ │ ├── package.json
│ │ └── tsconfig.json
│ ├── modules
│ │ ├── common
│ │ │ ├── http
│ │ │ │ ├── adapter.ts
│ │ │ │ ├── module.ts
│ │ │ │ ├── service.ts
│ │ │ │ └── __tests__
│ │ │ │ ├── module.spec.ts
│ │ │ │ └── service.spec.ts
│ │ │ ├── index.ts
│ │ │ ├── module.ts
│ │ │ └── __tests__
│ │ │ └── module.spec.ts
│ │ ├── global
│ │ │ ├── index.ts
│ │ │ ├── logger
│ │ │ │ ├── adapter.ts
│ │ │ │ ├── module.ts
│ │ │ │ ├── service.ts
│ │ │ │ └── __tests__
│ │ │ │ ├── module.spec.ts
│ │ │ │ └── service.spec.ts
│ │ │ ├── module.ts
│ │ │ ├── secrets
│ │ │ │ ├── adapter.ts
│ │ │ │ ├── enum.ts
│ │ │ │ ├── module.ts
│ │ │ │ ├── service.ts
│ │ │ │ └── __tests__
│ │ │ │ ├── module.spec.ts
│ │ │ │ └── service.spec.ts
│ │ │ └── __tests__
│ │ │ └── module.spec.ts
│ │ ├── index.ts
│ │ ├── jest.config.js
│ │ ├── package.json
│ │ ├── __tests__
│ │ │ └── module.spec.ts
│ │ └── tsconfig.json
│ └── utils
│ ├── documentation
│ │ ├── constants.ts
│ │ └── swagger.ts
│ ├── exception.ts
│ ├── filters
│ │ ├── http-exception.filter.ts
│ │ └── __tests__
│ │ └── http-exception.filter.spec.ts
│ ├── index.ts
│ ├── interceptors
│ │ ├── http-exception.interceptor.ts
│ │ ├── http-performance.interceptor.ts
│ │ └── __tests__
│ │ ├── http-exception.interceptor.spec.ts
│ │ └── http-performance.interceptor.spec.ts
│ ├── jest.config.js
│ ├── package.json
│ ├── static
│ │ └── htttp-status.json
│ ├── __tests__
│ │ └── exception.spec.ts
│ └── tsconfig.json
├── nest-cli.json
├── package.json
├── README.md
├── tests
│ ├── common.js
│ ├── index.js
│ ├── libs.js
│ ├── main-api.js
│ └── other-api.js
├── tools
│ └── eslint
│ └── package.json
├── tsconfig.build.json
└── tsconfig.json
├── tools
: Project tools like: eslint, prettier and etc.├── libs
: Application shared libs.├── libs ├── core
: Core business rules, don't use nestjs dependecies here, only class and rules that will be shared with other projects├── libs ├── modules
: Application modules, use only nestjs modules here, you can add modules like: http, databse etc.├── libs ├── utils
: Application utils, utilities that will shared with your monorepo.├── apps
: Monorepo Applications.├── tests
: Monorepo tests initializer like: env, mocks and configs.├── secrets
: Monorepo secrets.
The following is a list of all the people that have contributed to nest-boilerplate. Thanks for your contributions!
It is available under the MIT license. License