This template provides a starting point for building a NestJS application using Prisma as an ORM. It includes configuration for local development with Docker and instructions for running the application and tests.
To get started with this template, clone the repository and install the dependencies.
# Clone the repository
git clone https://github.com/AndreaDiazCorreia/nestjs-boilerplate-prisma.git
cd nestjs-boilerplate-prisma
# Install dependencies
pnpm install
This template includes a Docker configuration for running a PostgreSQL database. To start the PostgreSQL database:
docker-compose up -d
# Ensure the database is running by checking the container status:
docker ps
You can start the application in development, watch, or production mode.
# development mode
pnpm run start
# watch mode
pnpm run start:dev
# production mode
pnpm run start:prod
Run unit tests, end-to-end tests, or test coverage reports using the following commands:
# unit tests
pnpm run test
# e2e tests
pnpm run test:e2e
# test coverage
pnpm run test:cov
The application requires configuration via environment variables. Copy the .env.example to .env and modify it according to your environment:
cp .env.example .env
Edit .env
and set the DATABASE_URL
to connect to your Dockerized PostgreSQL database.
To generate the Prisma client and apply database migrations, use:
pnpm prisma generate
pnpm prisma migrate deploy
These commands set up the Prisma client and apply any migrations defined in the Prisma schema to your database.
To build the application for production deployment:
pnpm run build
This compiles the TypeScript code into JavaScript in the dist
directory.
Contributions are always welcome!