Streamline Your Backend Development with the Simple NestJS Boilerplate
Tags: nestjs, webdev, typescript, node
Published: 2023-06-19 09:44:52

# 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/stx3u3isvoj1g77qe8rd.jpg)

## 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](https://github.com/salnika/nestjs-boilreplate)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d7tu83g7ldt08j4pjri5.png)

## 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
```

To start the app and Postgres database, run:

```
docker-compose up --build
```

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/51izbuo4dyqoxdo5mcle.png)

## 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
```

## Contributions

Contributions are always welcome! Please check out the 'issues' tab on the [GitHub](https://github.com/salnika/nestjs-boilreplate) 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](https://github.com/salnika/nextjs-boilreplate)