-
NestJs starter git with basic middlewares ex. logging, response structure, tracing, validation and more.
-
Basic setup with mysql database
-
Docker-compose for setting up environment
npm install
npm run start:dev
create a .env file in the root directory with the below variables
POSTGRES_HOST=localhost
POSTGRES_PORT=3306
POSTGRES_USER=user
POSTGRES_DATABASE=db
POSTGRES_PASSWORD=password
Swagger documentation gets automatically generates, you just need to follow the conventions of entity creation.
swagger url - http://localhost:3000/docs
run e2e tests
npm run test:e2e
To create a new module we need few things in place, we can do it either via nest-cli or manually.
structure
module ->
- dto -> dto_file (filename.dto.ts) (one or more)
Here you define your data structure to be received in request body - entity -> entity_files (filename.entity.ts) (one or more) Here you define the db schema for an entity, nest picks it up and creates a table in your database using the schema defined.
- module controller file (module.controller.ts) Here you define your routing paths and methods to generate swagger docs for your defined path, use the ApiResponse module from swagger-ui, it will generate docs automatically for you.
- module service file (module.service.ts)
This is repository for the controllers where you call db functions.
Note: Remember to add any new module you have created in app.module file otherwise nest will not pickup your new module changes.
In pre-commit we are using husky as pre-commit so no need to define any pre-commit file inside .git/config folder you can refer what's inside hook by looking package.json file, look for husky.
It's to run the application standalone in any environment, currently it's defines postgres as dependency and uses it's port to servce the db
using docker-compose
docker-compose up