A progressive Node.js framework for building efficient and scalable server-side applications.
Nest framework TypeScript starter repository.
npm install# development
npm run start
# watch mode
npm run start:dev
# production
npm run start:prodThis project includes a full Docker setup for NestJS + PostgreSQL + TypeORM migrations & seeders.
docker compose up -dThis command will:
- Start the NestJS app container (
insurance_policy_app) - Start the PostgreSQL container (
insurance_policy_postgres)
docker compose run --rm migrateThis will execute all pending TypeORM migrations inside the container.
docker compose run --rm seedRuns the seeders defined in src/db/seeders/ (e.g. role.seeder.ts, user.seeder.ts, etc.).
docker compose psYou should see something like:
insurance_policy_postgres Up 0.0.0.0:5432->5432/tcp
insurance_policy_app Up 0.0.0.0:3000->3000/tcp
Once containers are up, the app is available at:
http://localhost:3000
http://localhost:3000/api
docker compose downTo reset all data (remove database volume):
docker compose down -v| Script | Command | Description |
|---|---|---|
npm run migration:generate <name> |
Generate new migration | Creates a migration from entity changes |
npm run migration:create <name> |
Create empty migration | Creates an empty migration file |
npm run migration:run |
Run migrations | Executes pending migrations |
npm run migration:revert |
Revert migration | Reverts the last executed migration |
npm run migration:show |
Show migrations | Lists all migrations and their status |
Example:
npm run migration:generate src/db/migrations/AddUserColumn
npm run migration:run🧠 Note: In Docker, you can also run migrations using:
docker compose run --rm migrate
Seeders populate initial data in the application.
# Local (requires npm dependencies)
npm run seed
npm run seed:dev
# Dockerized environment
docker compose run --rm seedrole.seeder.ts→ create default rolesuser.seeder.ts→ create admin & default users- All seeders registered in
main.seeder.ts
Once running, Swagger is available at:
http://localhost:3000/api
- JWT Authentication
- File Upload (JPEG, PNG, PDF)
- CORS Enabled
- Validation using class-validator
.envis automatically loaded into Docker containers.- Example configuration:
DB_HOST=db DB_PORT=5432 DB_USERNAME=postgres DB_PASSWORD=postgres DB_NAME=insurance_policy_db
Database data is stored in Docker volume pgdata:
docker volume lsTo clear database data:
docker compose down -v-
synchronize: falseindata-source.ts - Test migrations before deployment
- Backup production DB before running migrations
- Use strong passwords & secrets
- Set proper CORS origins
- Enable HTTPS in production
| Task | Local Command | Docker Command |
|---|---|---|
| Run App | npm run start:dev |
docker compose up -d |
| Run Migrations | npm run migration:run |
docker compose run --rm migrate |
| Run Seeders | npm run seed:dev |
docker compose run --rm seed |
| Stop All | Ctrl + C |
docker compose down |
Nest is MIT licensed.