Lab 15: Capstone — Typed API
Step 1: Setup
docker run -it --rm node:20-alpine sh
npm install -g typescript ts-node
mkdir /lab15 && cd /lab15
npm init -y
npm install express zod
npm install --save-dev @types/express @types/node typescript
cat > tsconfig.json << 'EOF'
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"moduleResolution": "node",
"strict": true,
"esModuleInterop": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
}
}
EOFStep 2: Typed Environment Variables
Step 3: Result<T, E> Error Handling
Step 4: Zod Schemas (Request/Response)
Step 5: Typed Middleware Stack
Step 6: Typed Service Layer
Step 7: Typed Router
Step 8: Capstone — Runnable API
Summary — Full Stack TypeScript Patterns
Layer
Pattern
Library
Last updated
