A progressive Node.js framework for building efficient and scalable server-side applications.
This is the backend service for Fullstack Monorepo Starter project, built with NestJS and Prisma.
- Node.js (v18 or higher)
- PNPM package manager
- PostgreSQL database
- From the root directory, install dependencies:
pnpm install
- Set up your environment variables:
cp .env.example .env
Edit the .env
file with your database credentials and other configuration.
- Run database migrations:
pnpm prisma migrate dev
- Start the development server:
pnpm dev
The API will be available at http://localhost:3001
apps/backend/
├── src/
│ ├── modules/ # Feature modules
│ ├── common/ # Shared code
│ ├── config/ # Configuration
│ └── main.ts # Application entry point
├── prisma/ # Database schema and migrations
└── test/ # Test files
- Create a new module:
pnpm nest generate module features/your-feature
- Generate components:
pnpm nest generate controller features/your-feature
pnpm nest generate service features/your-feature
- Update Prisma schema (
packages/database/prisma/schema.prisma
) - Generate Prisma client:
pnpm prisma generate
- Create a migration:
pnpm prisma migrate dev --name your_migration_name
- Swagger documentation is available at
/api/docs
when running in development mode - Keep API documentation up to date using Swagger decorators
# Unit tests
pnpm test
# E2E tests
pnpm test:e2e
# Test coverage
pnpm test:cov
- Follow NestJS architectural patterns
- Use DTOs for request/response validation
- Implement proper error handling
- Write unit tests for services
- Use guards for authentication/authorization
- Follow RESTful API conventions
- Add backend-specific dependencies:
pnpm add -w @nestjs/something
- Add development dependencies:
pnpm add -Dw @types/something
Key environment variables needed:
DATABASE_URL
: PostgreSQL connection stringJWT_SECRET
: Secret for JWT tokensPORT
: API port (default: 3001)
-
Database connection issues:
- Verify PostgreSQL is running
- Check database credentials in
.env
- Ensure migrations are up to date
-
Prisma issues:
- Run
pnpm prisma generate
after schema changes - Clear Prisma cache:
pnpm prisma generate --force
- Run
-
Module resolution errors:
- Check import paths
- Verify module is properly registered in
app.module.ts
For production deployment:
- Build the application:
pnpm build
- Start in production mode:
pnpm start:prod
For more deployment options, check the NestJS deployment documentation.
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.
- Author - Kamil Myśliwiec
- Website - https://nestjs.com
- Twitter - @nestframework
Nest is MIT licensed.