# api-development > Guidelines for building REST APIs with Express and TypeScript - Author: Sajeel Ahmad - Repository: Cjbuilds/Sheldon - Version: 20260126231347 - Stars: 0 - Forks: 0 - Last Updated: 2026-02-07 - Source: https://github.com/Cjbuilds/Sheldon - Web: https://mule.run/skillshub/@@Cjbuilds/Sheldon~api-development:20260126231347 --- --- name: api-development description: Guidelines for building REST APIs with Express and TypeScript version: "1.0.0" author: sheldon-example tags: - api - rest - express - typescript requires_context: - schema.md - api-design.md --- # API Development Skill ## Guidelines 1. Use Express Router for route organization 2. Use proper HTTP status codes (200, 201, 204, 400, 404, 500) 3. Validate all input with Zod schemas before processing 4. Use async route handlers with try/catch 5. Return consistent JSON response format with `data` wrapper ## Patterns - **Route organization**: Group routes by resource in separate files - **Validation**: Define Zod schemas alongside models, validate in route handlers - **Error handling**: Use a centralized error handler middleware - **Database access**: Use Knex query builder, never raw SQL strings - **UUIDs**: Generate with `crypto.randomUUID()` ## Response Format Success responses: ```json { "data": { ... } } ``` Error responses: ```json { "error": { "code": "ERROR_CODE", "message": "Description" } } ``` ## File Structure ``` src/ db/ connection.ts # Knex configuration migrations/ # Database migrations models/ user.ts # User model and Zod schema post.ts # Post model and Zod schema routes/ users.ts # User route handlers posts.ts # Post route handlers middleware/ error-handler.ts # Global error handler app.ts # Express app setup index.ts # Server entry point ```