• Stars
    star
    292
  • Rank 142,152 (Top 3 %)
  • Language
    TypeScript
  • Created almost 2 years ago
  • Updated 3 months ago

Reviews

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

Repository Details

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

Nestjs boilerplate Microservice API

In this microservice I used the best architecture concepts: onion architecture, DDD and clean architecture.

This microservice has only been tested on Linux and WSL2. If you have connection problems with Mongodb(replicaset) on MACos fix it and send me the PR.

Statements Branches Functions Lines
Statements Branches Functions Lines

Building and Running the application

  • install dependencies

    $ yarn
    
  • infra

     $ yarn infra
    
  • running

    • dev
      $ yarn start:dev
      
    • debug
      $ start:debug
      
    • production
      $ yarn start
      
  • build

    $ yarn build
    

CRUD Scaffolding

Creating a CRUD in Postgres and Mongo in seconds.

  • run
    $ yarn scaffold
    
  • Choose database for CRUD.
  • (x) POTGRES:CRUD
  • ( ) MONGO:CRUD
  • type module name (use the singular name)
  • After generating the CRUD, follow the instructions on the generated link.
  • Magic

CRUD features

  • List
    • mongo
      • search
      • pagination
      • sort
      • entity validation
    • postgres
      • search
      • pagination
      • sort
      • entity validation
  • Delete
    • mongo
      • Logical deletion
      • entity validation
    • postgres
      • Logical deletion
      • entity validation
  • Update
    • mongo
      • Update Partial entity
      • entity validation
    • postgres
      • Update Partial entity
      • entity validation
  • Create
    • mongo
      • entity validation
      • Not allow creating duplicates
    • postgres
      • entity validation

Postgres migrations

  • create
    $ yarn migration:create
    
  • run
    $ yarn migration:run
    

Tracing usage

Jeager Observability

Test

  • run
    $ yarn test
    
  • coverage
    $ yarn test:cov
    

Lint

  • lint
    $ yarn lint
    
  • prettier
    $ yarn prettier
    

Microservice architecture.

  • Docker
  • Observability
    • tracing
    • Jeager
  • Git hooks
    • Husky
  • Commitlint
  • Secrets Service
  • HTTP Service
  • Logger Service
    • traceid
    • pinojs
    • mongodb transport
  • Authentication
    • Login
    • Logout
  • Authorization
    • Role-based access
  • Error Handler
  • Libs Structure
  • Dependency Inversion Pattern
  • Usecase Pattern
  • Anti Corruption Layer Pattern
  • Interface Adapter Pattern
  • Generic Repository Pattern
    • Mongo Repository (mongooose)
    • Postgres Repository (sequelize)
  • Swaggger Documentation
  • Cache Service
    • Redis
    • NodeCache
  • Databse
    • mongo
      • Seed
      • Replica set
      • Transaction session
    • postgres
      • Migrations
      • Transaction session
  • Tests
    • unit
    • 100% coverage

-- App Skeleton

.
├── commitlint.config.js
├── docker-compose.yml
├── jest.config.ts
├── nest-cli.json
├── package.json
├── README.md
├── scripts
│   ├── mongo
│   │   ├── rs-init.sh
│   │   └── start-replicaset.sh
│   └── postgres
│       └── create-database.sql
├── src
│   ├── app.module.ts
│   ├── core
│   │   ├── cats
│   │   │   ├── entity
│   │   │   │   └── cats.ts
│   │   │   ├── repository
│   │   │   │   └── cats.ts
│   │   │   └── use-cases
│   │   │       ├── cats-create.ts
│   │   │       ├── cats-delete.ts
│   │   │       ├── cats-getByID.ts
│   │   │       ├── cats-list.ts
│   │   │       ├── cats-update.ts
│   │   │       └── __tests__
│   │   │           ├── cats-create.spec.ts
│   │   │           ├── cats-delete.spec.ts
│   │   │           ├── cats-list.spec.ts
│   │   │           ├── cats-update.spec.ts
│   │   │           └── user-getByID.spec.ts
│   │   └── user
│   │       ├── entity
│   │       │   └── user.ts
│   │       ├── repository
│   │       │   └── user.ts
│   │       └── use-cases
│   │           ├── __tests__
│   │           │   ├── user-create.spec.ts
│   │           │   ├── user-delete.spec.ts
│   │           │   ├── user-getByID.spec.ts
│   │           │   ├── user-list.spec.ts
│   │           │   ├── user-login.spec.ts
│   │           │   ├── user-logout.spec.ts
│   │           │   └── user-update.spec.ts
│   │           ├── user-create.ts
│   │           ├── user-delete.ts
│   │           ├── user-getByID.ts
│   │           ├── user-list.ts
│   │           ├── user-login.ts
│   │           ├── user-logout.ts
│   │           └── user-update.ts
│   ├── infra
│   │   ├── cache
│   │   │   ├── adapter.ts
│   │   │   ├── index.ts
│   │   │   ├── memory
│   │   │   │   ├── index.ts
│   │   │   │   ├── module.ts
│   │   │   │   ├── service.ts
│   │   │   │   └── types.ts
│   │   │   ├── redis
│   │   │   │   ├── index.ts
│   │   │   │   ├── module.ts
│   │   │   │   ├── service.ts
│   │   │   │   └── types.ts
│   │   │   └── types.ts
│   │   ├── database
│   │   │   ├── adapter.ts
│   │   │   ├── enum.ts
│   │   │   ├── index.ts
│   │   │   ├── mongo
│   │   │   │   ├── index.ts
│   │   │   │   ├── module.ts
│   │   │   │   ├── schemas
│   │   │   │   │   └── user.ts
│   │   │   │   ├── seed
│   │   │   │   │   └── create-user-admin.ts
│   │   │   │   └── service.ts
│   │   │   ├── postgres
│   │   │   │   ├── config.ts
│   │   │   │   ├── index.ts
│   │   │   │   ├── migrations
│   │   │   │   │   └── 20230416174316-create-cats-table.js
│   │   │   │   ├── module.ts
│   │   │   │   ├── schemas
│   │   │   │   │   └── cats.ts
│   │   │   │   └── service.ts
│   │   │   └── types.ts
│   │   ├── http
│   │   │   ├── adapter.ts
│   │   │   ├── index.ts
│   │   │   ├── module.ts
│   │   │   └── service.ts
│   │   ├── logger
│   │   │   ├── adapter.ts
│   │   │   ├── index.ts
│   │   │   ├── module.ts
│   │   │   ├── service.ts
│   │   │   └── types.ts
│   │   ├── module.ts
│   │   ├── repository
│   │   │   ├── adapter.ts
│   │   │   ├── index.ts
│   │   │   ├── mongo
│   │   │   │   └── repository.ts
│   │   │   ├── postgres
│   │   │   │   └── repository.ts
│   │   │   └── types.ts
│   │   └── secrets
│   │       ├── adapter.ts
│   │       ├── index.ts
│   │       ├── module.ts
│   │       └── service.ts
│   ├── libs
│   │   └── auth
│   │       ├── adapter.ts
│   │       ├── index.ts
│   │       ├── module.ts
│   │       ├── service.ts
│   │       └── types.ts
│   ├── main.ts
│   ├── modules
│   │   ├── cats
│   │   │   ├── adapter.ts
│   │   │   ├── controller.ts
│   │   │   ├── module.ts
│   │   │   ├── repository.ts
│   │   │   └── swagger.ts
│   │   ├── health
│   │   │   ├── controller.ts
│   │   │   ├── module.ts
│   │   │   └── __tests__
│   │   │       └── controller.spec.ts
│   │   ├── login
│   │   │   ├── adapter.ts
│   │   │   ├── controller.ts
│   │   │   ├── module.ts
│   │   │   └── swagger.ts
│   │   ├── logout
│   │   │   ├── adapter.ts
│   │   │   ├── controller.ts
│   │   │   ├── module.ts
│   │   │   └── swagger.ts
│   │   └── user
│   │       ├── adapter.ts
│   │       ├── controller.ts
│   │       ├── module.ts
│   │       ├── repository.ts
│   │       └── swagger.ts
│   └── utils
│       ├── database
│       │   ├── mongoose.ts
│       │   └── sequelize.ts
│       ├── decorators
│       │   ├── database
│       │   │   ├── mongo
│       │   │   │   ├── convert-mongoose-filter.decorator.ts
│       │   │   │   └── validate-mongoose-filter.decorator.ts
│       │   │   ├── postgres
│       │   │   │   ├── convert-paginate-input-to-sequelize-filter.decorator.ts
│       │   │   │   └── convert-sequelize-filter.decorator.ts
│       │   │   └── validate-database-sort-allowed.decorator.ts
│       │   ├── role.decorator.ts
│       │   ├── types.ts
│       │   └── validate-schema.decorator.ts
│       ├── entity.ts
│       ├── exception.ts
│       ├── filters
│       │   └── http-exception.filter.ts
│       ├── interceptors
│       │   ├── auth-guard.interceptor.ts
│       │   ├── http-exception.interceptor.ts
│       │   ├── http-logger.interceptor.ts
│       │   └── http-tracing.interceptor.ts
│       ├── middlewares
│       │   └── is-logged.middleware.ts
│       ├── pagination.ts
│       ├── request.ts
│       ├── search.ts
│       ├── sort.ts
│       ├── static
│       │   └── htttp-status.json
│       ├── swagger.ts
│       └── tests.ts
├── test
│   └── initializaion.ts
├── TRACING.md
├── tsconfig.build.json
└── tsconfig.json

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-monorepo

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.
TypeScript
305
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
19
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
14
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

coolvalidator

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

Excalibur-Dual-List

Component - Dual List directive in AngularJs and Bootstrap.
JavaScript
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

Mike.Padaria.Web.Projeto

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

HackZurich-Project

Project - Sending internal messages with misco meraki is easy
JavaScript
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-microservice-api-cli

JavaScript
2
star
27

nestjs-node-cache

Nestjs node cache module
TypeScript
2
star
28

PagFarma-Web

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

serverless-boilerplate

Serverless boilerplate
TypeScript
2
star
30

CalculandoNumerosComWCF

Academic Project - WCF Calculator
C#
2
star
31

express-typescript-boilperplate

TypeScript
2
star
32

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
33

node-generic-repositories

Type ORM | Sequelize Typescript | Mongoose
TypeScript
2
star
34

pay-force-source-pos

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

blue-hunter-backend

Desafio se você for um Dev Backend - Blue Hunter
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

calendarjs

JavaScript
1
star
39

CoparacaoEntreLINQeSQL

Academic Project - Comparison between LINQ to SQL
C#
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

LojaVirtualComAndroid

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

angular-tour-of-heroes

Tutorial - Tour of Heroes
TypeScript
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

electron-vuejs-typescript-boilerplate

In progress.
TypeScript
1
star
50

petshopv1

Project - System for Pet Shop Version 1 - With entity Framework 5, DataBase First and C # 5
C#
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