Fast Project Start with NestJS Boilerplate

Rodion Salnik
Frontend Weekly
Published in
2 min readMar 30, 2023

NestJS boilerplate is a project that contains all necessary libraries and solutions like auth, mailing, etc., for fast-starting your project using a classic REST API approach.
Created in August 2020, it now has more than 700 stars on Github and quite a big community helping to develop it feature.

Motivation

I’m working for the outsourcing company Brocoders, where we start a new project from scratch quite often. NestJS is a popular framework for Node.js, and we use it widely. However, setting up the project from scratch every time can be time-consuming, involving stuff such as configuring the database, migrations, seeding, mailing, sign-in, sign-up, translations, file uploading, etc.

To solve this problem, we created NestJS REST API Boilerplate with preconfigured basic features to reduce app setup time from 1 month to just a few hours.

At the time we started our own boilerplate, there wasn’t a great production-ready alternative, so we decided to develop our own solution, which eventually became quite popular in other companies too.

Modules and features

We put the most popular modules always requested by our clients and put them together into a Boilerplate. So we finally have such a list of features included in the box:

  • Database (PostgreSQL, TypeORM).
  • Seeds (test data)
  • Config Service (@nestjs/config).
  • Mailing (nodemailer, u/nestjs-modules/mailer).
  • Sign in and sign up via email
  • Forgot password
  • Social sign in (Apple, Facebook, Google, Twitter)
  • Admin and User roles
  • Serialization
  • Translations I18N (nestjs-i18n)
  • File uploads. Support local and Amazon S3 drivers
  • Swagger for API documentation
  • E2E and units tests
  • Docker
  • CI (Github Actions)

The main advantage of the NestJS Boilerplate by Brocoders is complementary frontend React Boilerplate that works seamlessly with this backend: Extensive React Boilerplate.

Quick start

In order to start a new project, you just need to follow the basic instructions:

  1. Clone repository
git clone --depth 1 https://github.com/brocoders/nestjs-boilerplate.git my-app

2. Go to folder, and copy env-example as .env

cd my-app/
cp env-example .env

3. Change DATABASE_HOST=postgres to DATABASE_HOST=localhost. Change MAIL_HOST=maildev to MAIL_HOST=localhost

4. Run additional container

docker compose up -d postgres adminer maildev redis

5. Install dependencies

npm install

6. Run migrations

npm run migration:run

7. Run seeds

npm run seed:run

8. Run the app in dev mode

npm run start:dev

9. Open http://localhost:3000

Summary

If you want to start a project faster — you can try NestJS REST API boilerplate. It’s pretty simple, supported by our company, and well-written (I hope :-) )

The main in our plans currently is to improve documentation and keep all the dependencies up-to-date. And if somebody has any other ideas or wants to become a contributor — we are always happy to meet new friends and accept pull requests.
Full Credits to the leading developer: Vlad Shchepotin 🇺🇦

--

--

Rodion Salnik
Frontend Weekly

Tech geek with 10+y exp | Startup Wise Guys alumni | Co-founder of CASERS and Brocoders