1.5 KiB
1.5 KiB
name, description, disable-model-invocation, argument-hint, context, agent
| name | description | disable-model-invocation | argument-hint | context | agent |
|---|---|---|---|---|---|
| api-endpoint | Scaffold a new REST API endpoint with input validation (Zod), error handling, types, and basic test. | true | [resource-name] | fork | backend-architect |
Scaffold API Endpoint
Create a production-ready API endpoint for resource $ARGUMENTS.
Steps
-
Read project context first:
- Check
docs/backend/architecture.mdfor module structure - Check
docs/backend/api-design.mdfor conventions (naming, pagination, errors) - Check
RECOMMENDATIONS.mdfor locked stack (framework, ORM, validation) - Look at existing endpoints in
apps/api/for patterns
- Check
-
Create endpoint with:
- RESTful routes:
GET /,GET /:id,POST /,PATCH /:id,DELETE /:id(only applicable ones) - Zod schemas for request validation (params, query, body)
- TypeScript types derived from Zod schemas
- Consistent error responses:
{ error: string, code: string, details?: unknown } - Pagination for list endpoints (
cursororoffset/limit) - Proper HTTP status codes (200, 201, 400, 404, 422, 500)
- RESTful routes:
-
Security considerations:
- Input validation before processing
- No SQL/NoSQL injection (parameterized queries)
- Auth middleware placeholder (if applicable)
- Rate limiting note (if public endpoint)
-
Files to create:
- Route handler / controller
- Zod validation schemas
- Types file (if separate)
- Basic integration test
-
Output: working code following project conventions. Note any assumptions made.