Set up a consistent API contract, reusable request/response helpers, and your first e-commerce endpoint. You'll learn the Next.js App Router API route model and establish the foundation that every other endpoint will reuse.
Overview
Syllabus
- Unit 1: Standardizing API Responses
- Observe the standard API response envelope
- Create the ApiSuccess/ApiError contract
- Implement success() and error() in response helpers
- Add parseJson() and a POST debug handler
- Unit 2: Validation and Domain Types
- Observe validation helpers and product type shapes
- Define Product domain and ListProductsInput DTO
- Implement validation helpers for query params
- Validate query, page, and pageSize in GET /api/products
- Unit 3: Wiring PostgreSQL Products
- Observe database wiring and products listing flow
- Implement query() and withTransaction() in the DB client
- Implement searchProducts() in productsRepo
- Wire products service and route to return DB results