• Stars
    star
    268
  • Rank 148,677 (Top 3 %)
  • Language
    TypeScript
  • Created over 2 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Monorepo boilerplate using Nestjs, authentication, docker, redis, secrets service, logs service, libs structure, anti corruption layer pattern, adapter pattern, dependency inversion pattern, mongodb, redis, swagger and tests.

Nestjs Monorepo Boilerplate

Check

Statements Branches Functions Lines
Statements Branches Functions Lines
Monorepo with nestjs
  • Docker

  • Secrets Service

  • Logs Service

    • Pinojs
    • Elastic
  • Observability

    • Jeager
    • Opentracing
  • Authentication

  • Error Handler

  • Libs Structure

  • Dependency Inversion Pattern

  • Anti Corruption Layer Pattern

  • Interface Adapter Pattern

  • Generic Repository Pattern

  • Swaggger Documentation

  • Redis

  • Mongodb

    • mongoose
    • multiples databases
  • Tests

    • unit
    • e2e
    • 90% coverage

Prerequisite

Instalation

  • install monorepo dependencies
    $ yarn monorepo:install
  • install project dependencies
    $ yarn workspace <workspaceName> install
  • install lib on project
    $ yarn workspace <workspaceName> add <libName>

Running local mongodb/redis/kibana/jeager

$ yarn infra:local
# http://0.0.0.0:8082/ to access mongo
# http://0.0.0.0:8081/ to access redis
# http://0.0.0.0:5601/app/home to access kibana
# http://0.0.0.0:16686/search to access jeager

Running the app

  • local

    $ yarn start:auth-api:dev
    $ yarn start:cats-api:dev
  • dev/hml/prd environment

    $ docker-compose up --build

Create Access User

  • http://0.0.0.0:8082/db/monorepo_auth/users
  • Click [New Document]
    {
       "_id": ObjectID(),
       "login": "<user>",
       "pass": "<pass>"
    }
    
  • now use this curl to get your access token
    curl -X 'POST'  'http://0.0.0.0:4000/api/login'    -H 'accept: application/json'  -H 'Content-Type:  application/json'  -d '{ "login": "<user>", "pass":  "<pass>" }'
    
  • use this token to access all monorepo internal APIs

workspace list
$ yarn workspaces info
  • @app/cats.api
  • @app/auth.api
  • @tools/eslint.config
  • @libs/utils
  • @libs/modules
  • @libs/core

Add new features

$ npm i -g @mikemajesty/monorepo-nestjs-cli
  • # type and choose your template
    $ monorepo-nestjs-cli

Tests

  • unit

    # Run monorepo tests
    $ yarn test
    # Run project tests
    $ yarn test main.api
    $ yarn test auth.api
    $ yarn test libs
  • e2e

    $ yarn test:e2e
    
    • coverage
    $ yarn test:coverage
    

Lint

  • Run monorepo lint

    $ yarn lint
  • Run project lint

    $ yarn workspace <workspaceName> lint
    

Build

  • Run project build
    $ yarn build <workspaceName>
    

-- App Skeleton

.
β”œβ”€β”€ apps
β”‚   β”œβ”€β”€ auth-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
β”‚   β”‚   β”‚       β”œβ”€β”€ login
β”‚   β”‚   β”‚       β”‚   β”œβ”€β”€ adapter.ts
β”‚   β”‚   β”‚       β”‚   β”œβ”€β”€ controller.ts
β”‚   β”‚   β”‚       β”‚   β”œβ”€β”€ module.ts
β”‚   β”‚   β”‚       β”‚   β”œβ”€β”€ service.ts
β”‚   β”‚   β”‚       β”‚   β”œβ”€β”€ swagger.ts
β”‚   β”‚   β”‚       β”‚   └── __tests__
β”‚   β”‚   β”‚       β”‚       β”œβ”€β”€ controller.e2e.spec.ts
β”‚   β”‚   β”‚       β”‚       └── service.spec.ts
β”‚   β”‚   β”‚       β”œβ”€β”€ module.ts
β”‚   β”‚   β”‚       β”œβ”€β”€ __tests__
β”‚   β”‚   β”‚       β”‚   └── module.spec.ts
β”‚   β”‚   β”‚       └── user
β”‚   β”‚   β”‚           β”œβ”€β”€ adapter.ts
β”‚   β”‚   β”‚           β”œβ”€β”€ entity.ts
β”‚   β”‚   β”‚           β”œβ”€β”€ module.ts
β”‚   β”‚   β”‚           β”œβ”€β”€ repository.ts
β”‚   β”‚   β”‚           β”œβ”€β”€ schema.ts
β”‚   β”‚   β”‚           └── __tests__
β”‚   β”‚   β”‚               └── repository.spec.ts
β”‚   β”‚   β”œβ”€β”€ tests
β”‚   β”‚   β”‚   └── initialization.js
β”‚   β”‚   β”œβ”€β”€ tsconfig.build.json
β”‚   β”‚   β”œβ”€β”€ tsconfig.json
β”‚   β”‚   └── yarn.lock
β”‚   └── cats-api
β”‚       β”œβ”€β”€ Dockerfile
β”‚       β”œβ”€β”€ jest.config.js
β”‚       β”œβ”€β”€ node_modules
β”‚       β”œβ”€β”€ package.json
β”‚       β”œβ”€β”€ src
β”‚       β”‚   β”œβ”€β”€ main.ts
β”‚       β”‚   └── modules
β”‚       β”‚       β”œβ”€β”€ cats
β”‚       β”‚       β”‚   β”œβ”€β”€ adapter.ts
β”‚       β”‚       β”‚   β”œβ”€β”€ controller.ts
β”‚       β”‚       β”‚   β”œβ”€β”€ entity.ts
β”‚       β”‚       β”‚   β”œβ”€β”€ module.ts
β”‚       β”‚       β”‚   β”œβ”€β”€ repository.ts
β”‚       β”‚       β”‚   β”œβ”€β”€ schema.ts
β”‚       β”‚       β”‚   β”œβ”€β”€ swagger.ts
β”‚       β”‚       β”‚   └── __tests__
β”‚       β”‚       β”‚       β”œβ”€β”€ controller.e2e.spec.ts
β”‚       β”‚       β”‚       └── repository.spec.ts
β”‚       β”‚       β”œβ”€β”€ 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
β”‚       β”œβ”€β”€ tests
β”‚       β”‚   └── initialization.js
β”‚       β”œβ”€β”€ tsconfig.build.json
β”‚       └── tsconfig.json
β”œβ”€β”€ CHANGELOG.md
β”œβ”€β”€ commitlint.config.ts
β”œβ”€β”€ CONTRIBUTING.md
β”œβ”€β”€ deploy
β”‚   └── production-version.sh
β”œβ”€β”€ docker-compose-local.yml
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ jest.config.e2e.ts
β”œβ”€β”€ jest.config.ts
β”œβ”€β”€ libs
β”‚   β”œβ”€β”€ core
β”‚   β”‚   β”œβ”€β”€ index.ts
β”‚   β”‚   β”œβ”€β”€ jest.config.js
β”‚   β”‚   β”œβ”€β”€ package.json
β”‚   β”‚   β”œβ”€β”€ tests
β”‚   β”‚   β”‚   └── initialization.js
β”‚   β”‚   └── tsconfig.json
β”‚   β”œβ”€β”€ modules
β”‚   β”‚   β”œβ”€β”€ auth
β”‚   β”‚   β”‚   └── token
β”‚   β”‚   β”‚       β”œβ”€β”€ adapter.ts
β”‚   β”‚   β”‚       β”œβ”€β”€ module.ts
β”‚   β”‚   β”‚       β”œβ”€β”€ service.ts
β”‚   β”‚   β”‚       β”œβ”€β”€ __tests__
β”‚   β”‚   β”‚       β”‚   └── service.spec.ts
β”‚   β”‚   β”‚       └── types.ts
β”‚   β”‚   β”œβ”€β”€ common
β”‚   β”‚   β”‚   β”œβ”€β”€ http
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ adapter.ts
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ module.ts
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ service.ts
β”‚   β”‚   β”‚   β”‚   └── __tests__
β”‚   β”‚   β”‚   β”‚       β”œβ”€β”€ module.spec.ts
β”‚   β”‚   β”‚   β”‚       └── service.spec.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ module.ts
β”‚   β”‚   β”‚   └── __tests__
β”‚   β”‚   β”‚       └── module.spec.ts
β”‚   β”‚   β”œβ”€β”€ database
β”‚   β”‚   β”‚   β”œβ”€β”€ adapter.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ connection
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ auth.ts
β”‚   β”‚   β”‚   β”‚   └── cats.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ entity.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ enum.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ repository.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ service.ts
β”‚   β”‚   β”‚   └── __tests__
β”‚   β”‚   β”‚       β”œβ”€β”€ repository.spec.ts
β”‚   β”‚   β”‚       └── service.spec.ts
β”‚   β”‚   β”œβ”€β”€ global
β”‚   β”‚   β”‚   β”œβ”€β”€ logger
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ adapter.ts
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ module.ts
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ service.ts
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ __tests__
β”‚   β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ module.spec.ts
β”‚   β”‚   β”‚   β”‚   β”‚   └── service.spec.ts
β”‚   β”‚   β”‚   β”‚   └── type.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
β”‚   β”‚   β”œβ”€β”€ redis
β”‚   β”‚   β”‚   β”œβ”€β”€ adapter.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ module.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ service.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ __tests__
β”‚   β”‚   β”‚   β”‚   └── service.spec.ts
β”‚   β”‚   β”‚   └── types.ts
β”‚   β”‚   β”œβ”€β”€ __tests__
β”‚   β”‚   β”‚   └── module.spec.ts
β”‚   β”‚   β”œβ”€β”€ tests
β”‚   β”‚   β”‚   └── initialization.js
β”‚   β”‚   └── tsconfig.json
β”‚   └── utils
β”‚       β”œβ”€β”€ documentation
β”‚       β”‚   β”œβ”€β”€ constants.ts
β”‚       β”‚   └── swagger.ts
β”‚       β”œβ”€β”€ exception.ts
β”‚       β”œβ”€β”€ filters
β”‚       β”‚   β”œβ”€β”€ http-exception.filter.ts
β”‚       β”‚   └── __tests__
β”‚       β”‚       └── http-exception.filter.spec.ts
β”‚       β”œβ”€β”€ index.ts
β”‚       β”œβ”€β”€ interceptors
β”‚       β”‚   β”œβ”€β”€ exception
β”‚       β”‚   β”‚   β”œβ”€β”€ http-exception.interceptor.ts
β”‚       β”‚   β”‚   └── __tests__
β”‚       β”‚   β”‚       └── http-exception.interceptor.spec.ts
β”‚       β”‚   └── logger
β”‚       β”‚       β”œβ”€β”€ http-logger.interceptor.ts
β”‚       β”‚       β”œβ”€β”€ http-tracing.interceptor.ts
β”‚       β”‚       └── __tests__
β”‚       β”‚           └── http-logger.interceptor.spec.ts
β”‚       β”œβ”€β”€ jest.config.js
β”‚       β”œβ”€β”€ middleware
β”‚       β”‚   └── auth
β”‚       β”‚       β”œβ”€β”€ is-logged.middleware.ts
β”‚       β”‚       └── __tests__
β”‚       β”‚           └── is-logged.middleware.spec.ts
β”‚       β”œβ”€β”€ package.json
β”‚       β”œβ”€β”€ request.ts
β”‚       β”œβ”€β”€ static
β”‚       β”‚   └── htttp-status.json
β”‚       β”œβ”€β”€ __tests__
β”‚       β”‚   └── exception.spec.ts
β”‚       β”œβ”€β”€ tests
β”‚       β”‚   β”œβ”€β”€ initialization.js
β”‚       β”‚   β”œβ”€β”€ mock-utils.ts
β”‚       β”‚   └── __tests__
β”‚       β”‚       └── mock-utils.spec.ts
β”‚       └── tsconfig.json
β”œβ”€β”€ nest-cli.json
β”œβ”€β”€ package.json
β”œβ”€β”€ README.md
β”œβ”€β”€ tests
β”‚   └── common-initialization.js
β”œβ”€β”€ tools
β”‚   └── eslint
β”‚       └── package.json
β”œβ”€β”€ tsconfig.build.json
β”œβ”€β”€ tsconfig.json
└── update-version.sh

Architecture

monorepo-diagram

  • β”œβ”€β”€ tools: Project tools like: eslint, prettier and etc.

  • β”œβ”€β”€ tests: Monorepo tests initializer like: env, mocks and configs.

  • β”œβ”€β”€ apps: Monorepo Applications.

  • β”œβ”€β”€ apps β”œβ”€β”€ auth-api : Authentication api, use to getting token to navigate between other projects.

  • β”œβ”€β”€ apps β”œβ”€β”€ cats-api : Use this API like an example to create other APIs.

  • β”œβ”€β”€ 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.

  • β”œβ”€β”€ libs β”œβ”€β”€ modules β”œβ”€β”€ global β”œβ”€β”€ secrets: Monorepo secrets.


The following is a list of all the people that have contributed Nestjs monorepo boilerplate. Thanks for your contributions!

mikemajesty

License

It is available under the MIT license. License

More Repositories

1

nestjs-microservice-boilerplate-api

Nestjs boilerplate microservice api | Mongodb CRUD - Postgres CRUD | Docker | Husky | Secrets service | HTTP service | Logs service | Authentication | Authorization | Error Handler | Swaggger Documentation | Mongo Generic Repository | Postgres Generic Repository
TypeScript
238
star
2

Chocobo-Date-Range-Picker

πŸ—“οΈ Component - The Date Range Picker easier to use in AngularJS.
JavaScript
23
star
3

Vue-Dual-List

πŸ“– Component - Dual list in VueJs and VueMaterial.
Vue
21
star
4

github-scrap-api

πŸ‘Ύ Project - Now getting information from your github is easy.
JavaScript
18
star
5

StormReport

πŸŒ€ Library - Create your reports using only annotations
C#
17
star
6

cooldatagridview

Library - Improve the Data Grid View UI | C# Windows Form.
C#
15
star
7

nestjs-mongoose-generic-repository

Nestjs mongoose generic repository
TypeScript
13
star
8

legend_of_github

βš”οΈ Project - The biggest battle between github accounts you've ever seen.
Vue
11
star
9

Vue-Month-Calendar

πŸ“† Component - Month Calendar using Vuejs and VueMaterial.
Vue
11
star
10

Excalibur-Dual-List

Component - Dual List directive in AngularJs and Bootstrap.
JavaScript
9
star
11

coolvalidator

Library - TextBox and object validator | C# Windows Form.
C#
9
star
12

Caixapadariav2

Project - Electronic system controls - Cash - Using: Entity Framework 6 data base First, C # 6 in MVC
C#
9
star
13

nestjs-convert-to-curl

Covert Axios error to curl
TypeScript
8
star
14

TutoriASP.NETMVC5-_DDD_EF_AutoMapper_IoC

Podcast - Working with ASP.NET MVC + DDD + 5 + EF6 AutoMapper + IoC
C#
7
star
15

E-Connect

Project - E-Connect is the chatbot to Improve the health of your business.
JavaScript
6
star
16

monorepo-nestjs-cli

JavaScript
6
star
17

Minha-Dll

Project - A DLL of my own to facilitate the creation of software
C#
5
star
18

SistemaDegerenciamentoComercial

Project - Electronic controls system - Using: ASP.NET MVC 5 Entity Framework Code First 6, Bootstrap, Ajax and jQuery
C#
5
star
19

CoolField

Project - A Lib to manipulate string in an easy way
C#
4
star
20

BeaconMusic

🎼 Project - A pub jukebox using google beacon.
JavaScript
4
star
21

coolreport

Project - Create your reports in many formats in a simple way.
C#
3
star
22

HackZurich-Project

Project - Sending internal messages with misco meraki is easy
JavaScript
3
star
23

Mike.Padaria.Web.Projeto

Project - System to learning, using: Asp.net Mvc 4 and entity Framework Data First base
C#
3
star
24

coolsync

Project - Multi thread in Windows Form now is easy.
C#
3
star
25

azure-function-docker-boilerplate

Azure function with Docker Boilerplate
TypeScript
2
star
26

nestjs-node-cache

Nestjs node cache module
TypeScript
2
star
27

PagFarma-Web

Project - A new sales channel between pharmacies and consumers.
JavaScript
2
star
28

pay-force-source-pos

Project - Now you no longer need a physical credit card.
JavaScript
2
star
29

serverless-boilerplate

Serverless boilerplate
TypeScript
2
star
30

nestjs-boilerplate-tests_examples

The best nestjs boilerplate using Anti-corruption Layer pattern, secrets, error handler, logger, Mysql, Docker and unit tests.
TypeScript
2
star
31

CalculandoNumerosComWCF

Academic Project - WCF Calculator
C#
2
star
32

express-typescript-boilperplate

TypeScript
2
star
33

node-generic-repositories

Type ORM | Sequelize Typescript | Mongoose
TypeScript
2
star
34

blue-hunter-backend

Desafio se vocΓͺ for um Dev Backend - Blue Hunter
JavaScript
1
star
35

calendarjs

JavaScript
1
star
36

MeuPrimeiroProjeto

Academic Project - Completed the 3rd semester of college
C#
1
star
37

pay-force-mobile

πŸ’° Project - Digital wallet and a new payment token, all put together in one app.
TypeScript
1
star
38

CoparacaoEntreLINQeSQL

Academic Project - Comparison between LINQ to SQL
C#
1
star
39

nestjs-microservice-api-cli

JavaScript
1
star
40

UsandoDataAnnotationNoWindowsForm

Test - ASP.NET MVC validators on the Desktop. Very cool results
C#
1
star
41

pay-force-web

Project - Have your own sales dashboard
JavaScript
1
star
42

angular-tour-of-heroes

Tutorial - Tour of Heroes
TypeScript
1
star
43

LojaVirtualComAndroid

Project - Developing a virtual store with Android.
Java
1
star
44

nestjs-boilerplate

Microservice using nestjs, docker, secrets service, logs service, anti corruption layer pattern, adapter pattern, dependency inversion pattern, swagger and tests.
TypeScript
1
star
45

CashMachine

Exercise - Cash Machine. Source code and comments accompanying the logic involved in it.
C#
1
star
46

CursoAngularJsDevMedia

Course - AngularJS [DevMedia]
JavaScript
1
star
47

blue-hunter-frontend

Desafio se vocΓͺ for um Dev Frontend - Blue Hunter
TypeScript
1
star
48

ConsultasComLinQ

Academic Project - basic queries to advanced with LINQ
C#
1
star
49

petshopv1

Project - System for Pet Shop Version 1 - With entity Framework 5, DataBase First and C # 5
C#
1
star
50

electron-vuejs-typescript-boilerplate

In progress.
TypeScript
1
star
51

NovidadesDoCSharp6

Course - What's new in C # 6 [DevMedia]
C#
1
star
52

Loja-Virtual

Project - Online shop - With Asp.net Mvc4 and Entity Framework database First
C#
1
star
53

ListaTelefonicaComAngularJs

Course - Creating a phone book with AngularJS
JavaScript
1
star
54

RefactoringImprovingCode

Book - Exercises of book Refactoring: Improving the Design of Existing Code
Java
1
star
55

Livro-ProfesssionalAsp.NetMVC5-

Book - Exercises Book PROFESSIONAL ASP.NET MVC 5
C#
1
star