NestJS Boilerplate supports TypeORM and Mongoose for working with databases. By default, TypeORM uses PostgreSQL as the main database, but you can use any relational database.
Switching between TypeORM and Mongoose is implemented based on the Dependency Inversion Principle (DIP). This makes it easy to choose the right database for your application architecture.
- Comfortable development (PostgreSQL + TypeORM)
- Comfortable development (MongoDB + Mongoose)
- Quick run (PostgreSQL + TypeORM)
- Quick run (MongoDB + Mongoose)
- Links
-
Clone repository
git clone --depth 1 https://github.com/brocoders/nestjs-boilerplate.git my-app
-
Go to folder, and copy
env-example-relational
as.env
.cd my-app/ cp env-example-relational .env
-
Change
DATABASE_HOST=postgres
toDATABASE_HOST=localhost
Change
MAIL_HOST=maildev
toMAIL_HOST=localhost
-
Run additional container:
docker compose up -d postgres adminer maildev
-
Install dependency
npm install
-
Run app configuration
You should run this command only the first time on initialization of your project, all next time skip it.
npm run app:config
-
Run migrations
npm run migration:run
-
Run seeds
npm run seed:run:relational
-
Run app in dev mode
npm run start:dev
-
Clone repository
git clone --depth 1 https://github.com/brocoders/nestjs-boilerplate.git my-app
-
Go to folder, and copy
env-example-document
as.env
.cd my-app/ cp env-example-document .env
-
Change
DATABASE_URL=mongodb://mongo:27017
toDATABASE_URL=mongodb://localhost:27017
-
Run additional container:
docker compose -f docker-compose.document.yaml up -d mongo mongo-express maildev
-
Install dependency
npm install
-
Run app configuration
You should run this command only the first time on initialization of your project, all next time skip it.
npm run app:config
-
Run seeds
npm run seed:run:document
-
Run app in dev mode
npm run start:dev
If you want quick run your app, you can use following commands:
-
Clone repository
git clone --depth 1 https://github.com/brocoders/nestjs-boilerplate.git my-app
-
Go to folder, and copy
env-example-relational
as.env
.cd my-app/ cp env-example-relational .env
-
Run containers
docker compose up -d
-
For check status run
docker compose logs
nestjs-boilerplate-installation.mp4
If you want quick run your app, you can use following commands:
-
Clone repository
git clone --depth 1 https://github.com/brocoders/nestjs-boilerplate.git my-app
-
Go to folder, and copy
env-example-document
as.env
.cd my-app/ cp env-example-document .env
-
Run containers
docker compose -f docker-compose.document.yaml up -d
-
For check status run
docker compose -f docker-compose.document.yaml logs
- Swagger (API docs): http://localhost:3000/docs
- Adminer (client for DB): http://localhost:8080
- MongoDB Express (client for DB): http://localhost:8081/
- Maildev: http://localhost:1080
Previous: Introduction
Next: Working with database