Skip to main content

NestJs

Typescript APIs with Node.js

Generators

The Nest plugin for Nx extends the generators provided by Nest. Any commands that can be used with the Nest CLI can also be used with the nx command.

tip

The --sourceRoot flag should be used for all Nest generators.

npx nx nest generate module /core/database --

Microservices

NestJs Microservices with NX

Source Code

  • NX
  • React
  • gRPC
  • Kafka
  • RabbitMQ

Migrations

postres

What is the best strategy?

TypeORM

Validation

Class Validator Library

Automapper

yarn add  @automapper/core, @automapper/classes, @automapper/nestjs class-transformer class-validator
yarn add -D @automapper/types

Architecture

Learn

Testing

Deployment

Command line

https://github.com/jmcdo29/nest-commander

Migrations

Package.json scripts

"migration:create": "npx typeorm migration:create -f ormconfig.local",
"migration:run": "ts-node --transpile-only ./node_modules/typeorm/cli.js migration:run -f ormconfig.local"

Setup and deploy

https://dev.to/clement/nestjs-postgresql-angular-within-nx-workspace-from-scratch-to-production-2im8

https://www.linkedin.com/pulse/nestjs-typeorm-migrations-nestor-iv%C3%A1n-scoles/

API Testing

Start with integration then add unit tests as needed.

  1. Mock data then database clean

The objectives we are trying to accomplish here are to:

ChecklistDoneNotes
test that middleware are set up (authentication, body validation)
test any side effects (database operation, API calls)
test the response of the HTTP request
test without any mock (or hardly any mock)
test each module isolated from each other
test automatically as part of CD/CI

Integration Tests

Easiest latest

Unit Tests

Once the project starts you focus on solving domain specific problems, not intfrastructur .

JobDescription
Stack SetupDebugging
Stack SetupTest on commit
Stack SetupTest Service
Stack SetupTest Controllers
Stack SetupTest Integration
Stack SetupMap Nest to DotNet

Schema

NameDescription
NestjsOfficial website
Nest Patterns