GitHub - fearlessforever/sample-nestjs-api: Restfull Api for Web Application using Nestjs · GitHub
Skip to content

fearlessforever/sample-nestjs-api

Repository files navigation

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

NPM Version Package License NPM Downloads CircleCI Coverage Discord Backers on Open Collective Sponsors on Open Collective Support us

Description

Nest framework TypeScript starter repository.

Sample / Feature Available

  • Simple usage controller , validation , service and route PR 5
  • Sample how to forward all log to file log ( each log file separate by date ) PR 13
  • Sample how to use rate-limiter PR 14
  • Sample how to use cache in app memory or using redis PR 16
  • Sample usage database ( prisma / ORM : model , type , interface , migrations ) in controller , service , route dan validator PR 8
  • Sample how to use queue ( require redis ) for heavy process ( background process ) / Scheduler PR 34
  • Sample how to use SSE ( Server Sent Events ) - realtime feature only server can send data PR 32
  • Sample how to use socket.io - realtime feature server <-> client send data PR 33
  • Sample how to use view engine templating for monolith ( traditional mvc ) and templating engine for email PR 31
  • Sample how to use CI/CD for nestjs application PR 20
  • Sample how to generate docker image ( optional: push image to docker hub by CI/CD release version ) PR 19
  • Sample Authentication / Authorization
  • Sample Implement Apache Kafka
  • Sample Implement gRPC
  • Sample how to send email ( required queue feature activate ) and using view engine templating like hbs , or ejs PR 35

Build & Running the app in docker [Production]

$ ./run docker-build
$ ./run docker-up
$ ./run docker-down
$ 
$ # run npm command in docker
$ ./run npm-in-docker run prisma version
$
$ # manually from docker, apply migration to db
$ ./run npm-in-docker run prisma migrate deploy
$
$ # run app in docker & migration as well if any available
$ # NOTE: this might take a while because of downloading prisma engine & deploy db changes
$ ./run docker-up --profile migration

Requirement & Optional Feature if Activate

  • nodejs: v18.16
  • nestjs: ^10.0.0
  • redis:7.2-rc3 ( optional )
  • database: postgresql, mysql or mariadb ( optional )

For Debuging Postman file Environment & Collections

Docker Image ( production ready )

$ docker pull fearlessforever/nestjs-app:latest
$ #run the image and send to background
$ docker run -d \
  --name my-nestjs \
  -v $(pwd)/../logs:/logs \
  -e IS_FORWARD_LOG_TO_FILE=true \
  -p 3000:3000 \
  --expose 3000 \
  fearlessforever/nestjs-app:latest \
  npm run start:prod
$ #stop / kill it process
$ docker kill my-nestjs
$ #remove unused container
$ docker rm my-nestjs

Installation

$ npm install

DB Operation

$ npm run prisma migrate dev -- --name init_app_db
$ npm run prisma generate
$ npm run prisma migrate deploy

Running the app

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Test

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

Support

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.

License

Nest is MIT licensed.

About

Restfull Api for Web Application using Nestjs

Resources

Stars

Watchers

Forks

Packages

Contributors