When building an API ($ARGUMENTS):
Define the endpoint:
- HTTP method and route
- Request params, query, body schema
- Response format and status codes
Implement with best practices:
- Input validation (zod, joi, or manual)
- Proper error handling with status codes
- TypeScript types for request/response
- Consistent response format:
{ data, error, message }
Add middleware as needed:
- Authentication/authorization
- Rate limiting
- Request logging
- CORS headers
Error responses:
- 400: Bad request (validation errors)
- 401: Unauthorized
- 403: Forbidden
- 404: Not found
- 500: Internal server error
Generate tests for the endpoint covering happy path and error cases