Nest framework TypeScript starter repository.
Some core functions required for Global Trace are provided by diginex as an external library. Use the following to set the access token value for GITLAB_DIGINEX_TOKEN.
SETX GITLAB_DIGINEX_TOKEN gldt-9WSPQzgRCNGxyGnVn8Ds
export GITLAB_DIGINEX_TOKEN=gldt-9WSPQzgRCNGxyGnVn8Ds
.
├── charts -> Helm chart
│ └── usdol-backend
│ ├── charts
│ ├── environments
│ └── templates
├── src
│ ├── config
│ ├── core
│ │ ├── databases
│ │ ├── entities
│ │ ├── exceptions
│ │ ├── http
│ │ │ ├── controllers
│ │ │ └── guards
│ │ ├── repositories
│ │ │ ├── criterias
│ │ │ └── eloquents
│ │ ├── requests
│ │ ├── services
│ │ ├── tests
│ │ └── transformers
│ ├── mails
│ │ ├── adapters
│ │ ├── constants
│ │ ├── interfaces
│ │ ├── mails
│ │ └── services
│ └── users -> Module user
│ ├── databases
│ │ ├── factories -> Contains factories
│ │ └── migrations -> Contains migrations
│ ├── entities -> Contains entities
│ ├── enums -> Contains enums
│ ├── http
│ │ ├── controllers -> Contains controllers
│ │ ├── guards -> Contains guards
│ │ ├── midlewares -> Contains midlewares
│ │ └── requests -> Contains request
│ ├── mails -> Contains emails
│ ├── repositories -> Contains repositories
│ ├── resources -> Contains information such as views, fonts, css...
│ │ └── mails -> Contains views for email
│ ├── services -> Contains services
│ ├── tests -> Contains unit test, e2e test
│ └── transformers -> Contains transformers
└── test
Some code examples display a file that has one or more similarly named companion files. For
example, hero.controller.ts
and hero.service.ts
Apply the single responsibility principle (SRP) to all components, services, and other symbols. This helps make the app cleaner, easier to read and maintain, and more testable.
Nestjs is inspired by Angular, so you can use some rules from Angular.
Do define small functions
Consider limiting to no more than 75 lines.
Consider limiting files to 400 lines of code.
Do use consistent names for all symbols.
Do follow a pattern that describes the symbol's feature then its type. The recommended pattern is feature.type.ts
.
Do use dashes to separate words in the descriptive name.
Do use dots to separate the descriptive name from the type.
Do use consistent type names for all components following a pattern that describes the component's feature then its
type. A recommended pattern is feature.type.ts
.
Do use conventional type names including .service, .component, .pipe, .module
, and .directive
. Invent additional
type names if you must but take care not to create too many.
Do use consistent names for all assets named after what they represent.
Do use upper camel case for class names.
Do match the name of the symbol to the name of the file.
Do append the symbol name with the conventional suffix (such as Component, Directive, Module, Pipe, or Service) for a thing of that type.
Do give the filename the conventional suffix (such as .component.ts
, .directive.ts
, .module.ts
, .pipe.ts
,
or .service.ts
) for a file of that type.
Do name test specification files the same as the component they test.
Do name test specification files with a suffix of .spec.ts
Do name end-to-end test specification files after the feature they test with a suffix of .e2e-spec.ts
Normally, naming the database will be an underscore (like user_plan
), but to synchronize the entire standard on the system with NestJs, we will use camelCase for column and PascalCase for table.
Example: user_plan
-> userPlan
or UserPlan
This will cause some problems when querying pure, be careful with it.
Must be singular
Must be a noun
Must be PascalCase
All inputs and outputs must be in universal time.
Must be timestamp
All APIs must have an e2e test.
Complex functions must have unit tests.
Postgres: 11
docker-compose up -d
$ npm install
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
You need link cli first npm link
wz-command make-migration create-user-table -- --module=<module-name> --create=User --update=User
wz-command make-module
wz-command make-e2e-test user-controller -- --module=<module-name>
wz-command make-service user -- --module=<module-name>
wz-command make-entity user -- --module=<module-name>
wz-command make-controller user -- --module=<module-name>
wz-command make-dto user -- --module=<module-name>
wz-command make-repository user -- --module=<module-name>
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov
Return a data object
Example :
{
"message": null,
"errors": {
"email": {
"messages": [
"email should not be empty"
]
},
"password": {
"messages": [
"password must be longer than or equal to 15 characters",
"password must be a string"
]
},
"test": {
"children": {
"email": {
"messages": [
"email should not be empty"
]
},
"password": {
"messages": [
"password must be longer than or equal to 15 characters",
"password must be a string"
]
}
},
"messages": []
}
}
}
{
"message": "Enterprise not found",
"errors": null
}
{
"message": "Unauthorized",
"errors": null
}
When adding new roles or permissions, we need to:
roles|permissions-DD-MM-YYYY-v(n)
When adding or removing role in existed role_permission_mapping object, we need to:
At local: You can run this command to crawl the locations
Example :wz-command crawl-location
After having built the application, you need to execute to the docker container then run this command which is a little different
Example :node dist/cli.js crawl-location
usdol.uat.dgnx.io
so that we need to add it in the list split by the comma ,
with no space
. At the local, such as the FE run at localhost:3010 we will have the WHITELIST_DOMAINS like this: usdol.uat.dgnx.io,localhost:3010
Global Trace Protocol <global-trace-protocol@dev.dgnx.io>
FIREBASE_DYNAMIC_LINK_DOMAIN, FIREBASE_DYNAMIC_LINK_API_KEY, FIREBASE_DYNAMIC_LINK_APN, FIREBASE_DYNAMIC_LINK_IBI
WEB_2_PDF_API_URL
and its private key for security stuff WEB_2_PDF_API_KEY