This project is an example of a NestJS application using Prisma as the ORM and Zod for schema validation. The application includes features such as setting up Zod schemas for request validation, integration tests, and ensuring a clean architecture.
- NestJS: A progressive Node.js framework for building efficient, reliable, and scalable server-side applications.
- Prisma: Next-generation ORM for Node.js and TypeScript.
- Zod: TypeScript-first schema declaration and validation library.
- Integration Tests: Ensuring a clean separation between development and test databases.
- Custom Validation Decorators: Streamlined application of Zod schemas and validation pipes.
-
Clone the repository:
git clone <repository-url> cd <repository-directory>
-
Install dependencies:
pnpm install
-
Copy
.env.example
to.env
and update the environment variables:cp .env.example .env
-
Copy
.env.example
to.env.test
for the test environment:cp .env.example .env.test.local
-
Update the
DATABASE_URL
in both.env
and.env.test.local
with your database connection strings.
-
Run database migrations for dev environment:
npm run migrate:dev
-
Start the application:
npm run start:dev
Run database migrations for the test database:
pnpm migrate:local-test
Run e2e tests using Jest:
npm run test:local-e2e
To create a new migration, run:
pnpx prisma migrate dev --name <migration-name>