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.exampleto.envand update the environment variables:cp .env.example .env
-
Copy
.env.exampleto.env.testfor the test environment:cp .env.example .env.test.local
-
Update the
DATABASE_URLin both.envand.env.test.localwith 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-testRun e2e tests using Jest:
npm run test:local-e2eTo create a new migration, run:
pnpx prisma migrate dev --name <migration-name>