niraj-khatiwada/ultimate-nestjs-boilerplate
Advanced Nest.js boilerplate for scalable startups⚡
Advanced Nest.js boilerplate for scalable startups.
No download data available
No tracked packages depend on this.
.env files ready:cp ./.env.example ./.env
cp ./.env.docker.example ./.env.docker
pnpm docker:dev:up
docker exec -it nestjs-boilerplate-server sh
pnpm migration:up
Rolling our own auth is doable but maintaining all kinds of authentication types ourselves has been found out to be a challenging task. Moreover, rolling our own auth poses security risks. That's why this boilerplate uses Better Auth for everything related to authentication. All of the industry standard authentication kinds are ready to be used out of the box so that you focus on building features rather than worrying about auth shenanigans:
You can find the frontend client setup here. You can find your auth API documentation by visiting /api/auth/reference

You can automatically generate and use all of your backend API in frontend in just one command, thanks to Swagger and OpenAPI spec. Running pnpm codegen on the frontend (example repo) will automatically generate all API's bootstrapped with Tanstack Query ready to be used with just one import. See complete example here

Prometheus & Grafana are available with Docker setup only. You might only need to monitor your server or database when the user base grows or when you want to debug some specific issues. That's why this step is completely optional. If you want to monitor your server or database, just enable monitoring profile in your .env i.e. COMPOSE_PROFILES=monitoring.
Server Monitoring Dashboard:

Database Monitoring Dashboard:

pnpm docker:dev:up
pnpm docker:dev:down
pnpm docker:prod:up
pnpm docker:prod:down
sh ./bin/deploy.sh
or run workflow .github/workflows/main.yml via GitHub Actions.
Let's face it, it is not practical to just create some random html email templates and inject your variables and send it to your clients. Your email templates must be checked for spam, CSS compatibility for different email clients, accessibility, responsiveness, etc. You need to make sure all these checks are passed so that your emails don't end up in spam folder. React Email is perfect fit for this. It uses React and provides many responsive email component blocks so that you can test all of the things mentioned earlier in your local development.
NOTE: We use React Email only in local development. We don't ship React and it's packages in production at all(you can see that all of the React packages are dev only). After our email templates have been created, we convert the .tsx files into static html files at build time and NodeMailer uses that html file from our backend. All of these things are handled automatically, you don't have to do any extra setup.
pnpm email:dev
.tsx templates file into html(.hbs). This is already handled in post build (build script).pnpm email: build
.tsx email files inside templates/ folder and convert them to html(.hbs). This is already handled when you run your Nest.js server (in start:dev script).pnpm email:watch

In local you can easily test your email by using MailPit email client that ships with it's own SMTP server. The SMTP server will automatically run when you run your docker in development mode:
pnpm docker:dev:up
After that, just visit http://localhost:<DOCKER_MAIL_CLIENT_PORT>. You can find DOCKER_MAIL_CLIENT_PORT on .env.docker. By default, it will run on http://localhost:18025

Visualize all of your project modules and their dependencies. Also, detect circular dependencies.
NOTE: Make sure Graphviz is installed first.
pnpm graph:app
pnpm graph:circular
Visualize your database entities and their relationships.
pnpm erd:generate
This boilerplate is extended from nestjs-boilerplate