Lab 15: Capstone — API Platform
Overview
Step 1: Project Structure (Hexagonal Architecture)
mkdir -p api-platform/src/{routes,services,repos,middleware}
cd api-platform
npm init -yapi-platform/
├── src/
│ ├── routes/ # HTTP entry points (adapters)
│ ├── services/ # Business logic (core)
│ ├── repos/ # Data access (adapters)
│ └── middleware/ # Cross-cutting concerns
├── app.js # App factory
└── server.js # Entry point (binds port)Step 2: Express Router with JSDoc + Zod Validation
Step 3: Redis Caching Middleware (Cache-Aside Pattern)
Step 4: JWT Authentication Middleware
Step 5: Rate Limiting (Sliding Window)
Step 6: Structured Logging with Pino
Step 7: Health Check Endpoint
Step 8 (Capstone): Graceful Shutdown + Full Platform Assembly
server.js — Wiring Everything Together
server.js — Wiring Everything Togetherdocker-compose.yml
docker-compose.ymlDockerfile
DockerfileGraceful Shutdown Verification
Summary
Component
Technology
Pattern
Last updated
