DEV Community

Salnik a
Salnik a

Posted on

Streamline Your Backend Development with the Simple NestJS Boilerplate

Article Title: Streamline Your Backend Development with the Simple NestJS Boilerplate

Introduction

The early stages of backend development often involve a lot of setup and configuration, which can slow down progress on the actual functionality of your application. Wouldn't it be great to jumpstart this process and focus more on writing the code that matters to your project? That's where boilerplates come into play. Today, I'm going to introduce you to a simple yet effective NestJS boilerplate that can help you kickstart your backend projects in no time.

Image description

The NestJS Boilerplate

The NestJS boilerplate is a bare-bones yet powerful project template designed to speed up the setup process for your NestJS applications. It includes pre-configured Swagger for API documentation, a Postgres database for data storage, Typeorm for interacting with the database, and a Dockerized app and database setup for easy deployment. You can find it on Github

The goal of this boilerplate is to remain simple and effective, allowing developers to get their projects off the ground quickly without getting bogged down in setup.

Image description

Features

This NestJS boilerplate comes with the following key features:

  • Swagger Documentation: Helps you design, build, document, and consume your APIs.

  • Postgres Database: A powerful, open-source object-relational database system that uses and extends the SQL language.

  • Typeorm: An ORM that can run in NodeJS and can be used with TypeScript and JavaScript.

  • Dockerized App and DB: A docker setup for both the app and the database to make deployments a breeze.

Getting Started

Setting up with this boilerplate is quite straightforward. First, ensure you have the following prerequisites installed on your machine:

  • NodeJS 18.10
  • Yarn
  • Docker
  • Docker-compose

Next, install the dependencies by running:

yarn install
Enter fullscreen mode Exit fullscreen mode

To start the app and Postgres database, run:

docker-compose up --build
Enter fullscreen mode Exit fullscreen mode

The app will be available on port 3000: http://localhost:3000

API Documentation

Your API documentation is available at http://localhost:3000/api. This documentation is powered by Swagger, making it interactive and easy to navigate.

Image description

Database Migrations

This boilerplate uses TypeORM to manage database migrations. To create a new migration or run existing migrations, use the following commands respectively:

yarn run migration:create ./src/migration/NAME_OF_THE_MIGRATION
yarn run migration:run
Enter fullscreen mode Exit fullscreen mode

Contributions

Contributions are always welcome! Please check out the 'issues' tab on the GitHub page to find something you'd like to work on.

Companion Frontend NextJS Boilerplate

If you need a frontend solution to pair with this NestJS boilerplate, a simple NextJS boilerplate is also available. It's designed to work seamlessly with this backend boilerplate, providing a complete full-stack solution for your projects. Check it out on GitHub

Top comments (0)