API Project Set-Up [Node]
Details
What You'll Build
A fully working Employee Management REST API with:
- CRUD endpoints (POST, GET, PATCH, DELETE /employees)
- Pagination, sorting, and filtering on the list endpoint
- Strong runtime validation via zod
- A typed, schema-first database layer via Drizzle ORM
- Environment-aware configuration (development / production)
- A multi-database PostgreSQL setup orchestrated via Docker Compose
- A seed script to populate sample data
- A REST Client app.http file to exercise every endpoint
What You'll Learn
By the end of this workshop you'll be able to:
- Scaffold a NestJS application from scratch with `@nestjs/cli`.
- Containerize a Node.js API using a multi-stage Dockerfile and Docker Compose.
- Run PostgreSQL in Docker with auto-created databases via init scripts.
- Load environment variables dynamically from `.env.${NODE_ENV}` files.
- Wire up Drizzle ORM as a global NestJS module with proper lifecycle hooks.
- Define a database schema in TypeScript and generate SQL migrations.
- Validate request bodies and query params with zod using custom decorators (no class-validator).
- Implement pagination, sorting, and filtering the right way.
- Translate database errors (e.g. unique_violation) into proper HTTP responses (409 Conflict).
- Write a seed script that works across environments.
- Test the API end-to-end using the VS Code REST Client.
Prerequisites
Please install before the event:
- Node.js : ≥ 22 Download here
- pnpm: ≥ 9
- `corepack enable && corepack prepare pnpm@latest --activate`
- Docker Engine: ≥ 20.10 (With the Compose v2 plugin, `docker compose`, not `docker-compose`)
- Git: latest Download here
- VS Code: latest Download here
- VS Code extensions:
- REST Client, ESLint, Prettier
A working internet connection is required to download Docker images and npm packages.
Related topics
nodeJS
PostgreSQL
Typescript
Software Development
Docker
