Skip to content

A scalable NestJS boilerplate integrated with Prisma ORM, built with TypeScript and Node.js. It includes Docker support, Swagger API docs, automated Prisma migrations and seeding, VS Code debugging, real-time communication via Soketi, and email testing with Mailpit. Ideal for kickstarting production-ready server-side applications.

Notifications You must be signed in to change notification settings

DishenMakwana/nestjs-prisma

Repository files navigation

nestjs-api

Getting started

  • use volta for node version management and use project node version define in package.json
yarn install
yarn run prisma:generate
yarn run build
cp .env.dev .env

Changes in .env file according the project and change in prisma.schema file according to the usage

Note: One can delete the migration for the first time, if there is change in the schema of user.

Migration

yarn run prisma:migrate

If prompt to enter migration name give appropriate name

yarn run prisma:seed

UI for database / Model

yarn run prisma:studio

Server

Development - yarn run start:dev
Production - yarn run start
Staging - yarn run start or yarn start

API Docs / Swagger

Go to: {base-url}/api/docs Enter below credentials:

username: admin
password: Admin@123

Generate only migration file for changes in schema

npx prisma migrate dev --create-only

Share Live API

npx localtunnel --port 5003 --subdomain=nestjs-api

Run debugger

  • add .vscode/launch.json file
{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Attach",
      "port": 9229,
      "type": "node",
      "request": "attach",
      "skipFiles": ["<node_internals>/**"]
    }
  ]
}

Generate ES512 private key for JWT Secret

openssl ecparam -name secp521r1 -genkey -noout -out private.pem

Mailpit for testing email

docker compose -f docker-compose-mailpit.yml up -d
  • set mailpit config in .env file
MAIL_HOST=localhost
MAIL_PORT=1025

Soketi for communication between server and client in real time using pusher

docker compose -f docker-compose-soketi.yml up -d
  • update inbound rules in aws security group for port 6001
  • if you are using cloudpanel then update inbound rules in cloudpanel for port 6001 from Admin Area Security Tab

Connect Cloudpanel database locally

  • update inbound rules in cloudpanel for port 3306 from Admin Area Security Tab
  • create one user with all privileges to access database locally

TODO

  • Store email sent with subject in database with timestamp
  • Store otp expiry time and maintain separate table for otp
  • For reset-password use link instead of otp

About

A scalable NestJS boilerplate integrated with Prisma ORM, built with TypeScript and Node.js. It includes Docker support, Swagger API docs, automated Prisma migrations and seeding, VS Code debugging, real-time communication via Soketi, and email testing with Mailpit. Ideal for kickstarting production-ready server-side applications.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •