creating NestJS project and generate nest artifacts with-in monorepo.
An Introduction to
Workspace
Prerequisites
Install Global Packages
npm -g remove @nestjs/cli
npm -g add @nestjs/cli
Scaffold Project
adding code dependencies
# generate Yeti API app
# `nest generate app yeti-api`
ng g @nrwl/nest:app yeti-api --frontend-project=yeti-app --linter=eslint --tags="domain:yeti,type:api,platform:node"
# generate `config` lib
ng g @nrwl/nest:lib config --global=true --directory=nestjs \
--controller=false --service=true --publishable=true \
--target=es2020 --tags="domain:yeti,type:api,platform:node" --dry-run # use prefix @yeti
# Add nestjs
npm i @nestjs/{common,core,microservices,swagger,websockets,typeorm,passport,elasticsearch} --workspace=apps/api
# fastify-* are optional. use only if you want to replace express with fastify
npm i fastify fastify-formbody fastify-swagger --workspace=apps/api
npm i -D @nestjs/testing @nestjs/schematics --workspace=apps/api
check versions
# check of nest installed
cd apps/api
nest info
Dependencies
adding 3rd party modules/libs
npm i pg dotenv helmet web-push nest-router nodemailer pug class-validator class-transformer --workspace=apps/api
npm i passport passport-jwt @xmlking/jwks-rsa --workspace=apps/api
npm i --workspace=apps/api -D rimraf nodemon tsconfig-paths ts-loader
npm i --workspace=apps/api -D jest ts-jest @types/jest supertest @types/supertest
npm i --workspace=apps/api -D @types/nodemailer
npm i --workspace=apps/api -D @types/socket.io
npm i --workspace=apps/api -D @types/passport@0.4.2 @types/passport-jwt
npm i --workspace=apps/api -D @types/web-push
npm i --workspace=apps/api -D @types/helmet
# scaffold echo module
nest g module app/echo -p api --dry-run
nest g controller app/echo -p api --dry-run
# scaffold core module
nest g module app/core -d
nest g guard auth app/core -d
# scaffold shared module
nest g module app/shared -d
nest g gateway eventbus app/shared -d
# scaffold user module
nest g module app/user -d
nest g class user.entity app/user --no-spec -d
nest g controller user app -d
nest g service user app -d
nest g controller profile app/user -d
nest g service profile app/user -d
nest g class profile/profile.entity app/user --no-spec -d
nest g controller email app/user -d
# scaffold email module
nest g module app/email -d
nest g service email app/email --flat -d
# scaffold auth module
nest g module app/auth -d
nest g class auth.exception app/auth --no-spec -d
# scaffold chat module
nest g module app/chat -d
nest g controller chat app/chat --flat -d
nest g service chat app/chat --flat -d
nest g gateway chat app/chat --flat -d
# scaffold external module
nest g module app/external -d
nest g controller weather app/external -d
nest g service weather app/external -d
# scaffold project module
nest g module app/project -d
nest g controller kubernetes app/project -d
nest g service kubernetes app/project -d
nest g class cluster/cluster.entity app/project --no-spec -d
nest g controller cluster app/project -d
nest g service cluster app/project -d
nest g class project.entity app/project --no-spec -d
nest g controller project app -d
nest g service project app -d
# scaffold notifications module
nest g module app/notifications -d
nest g controller notification app/notifications -d
nest g service notification app/notifications -d
nest g service notification/push app/notifications --flat --no-spec -d
nest g class notification/notification.entity app/notifications --no-spec -d
nest g controller subscription app/notifications -d
nest g service subscription app/notifications -d
nest g class subscription/subscription.entity app/notifications --no-spec -d
You could also use `ng g` if you `npm i -D @nestjs/schematics`
ng g @nestjs/schematics:module game --path app --source-root apps/api/src -d
ng g @nestjs/schematics:controller match --path app/game --source-root apps/api/src -d
ng g @nestjs/schematics:service match --path app/game --source-root apps/api/src -d
ng g @nestjs/schematics:class match/match.entity --path app/game --source-root apps/api/src --spec -d