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 Hexagonal Architecture. This makes it easy to choose the right database for your application.
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
to DATABASE_HOST=localhost
Change MAIL_HOST=maildev
to MAIL_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.
If you want to contribute to the boilerplate, you should NOT run this command.
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
https://github.com/user-attachments/assets/136a16aa-f94a-4b20-8eaf-6b4262964315
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
to DATABASE_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.
If you want to contribute to the boilerplate, you should NOT run this command.
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
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
Previous: Introduction
Next: Architecture