REST API Implementation
Implement a complete REST API with validation, error handling, and documentation.
Prompt template
Implement a REST API for [RESOURCE/FEATURE] in [PROGRAMMING LANGUAGE] with [FRAMEWORK]. **API Endpoints:** - GET /[RESOURCE] — List with pagination and filtering - GET /[RESOURCE]/:id — Get single resource - POST /[RESOURCE] — Create new resource - PUT /[RESOURCE]/:id — Update resource - DELETE /[RESOURCE]/:id — Delete resource **Implement for each endpoint:** 1. **Request Validation:** Input validation with [Zod/Joi/class-validator] 2. **Controller Logic:** Clean separation of routing and business logic 3. **Service Layer:** Business logic in separate service class 4. **Error Handling:** Standardized error responses with HTTP status codes 5. **Authentication:** Middleware for JWT/API key validation 6. **Logging:** Request/response logging with correlation IDs **Additionally:** - OpenAPI/Swagger documentation - Rate limiting middleware - CORS configuration - Integration tests for all endpoints
Replace placeholders in [square brackets]: [RESOURCE/FEATURE][PROGRAMMING LANGUAGE][FRAMEWORK][RESOURCE][Zod/Joi/class-validator]
How to use this template
Copy the prompt, replace the placeholders in square brackets with your details and paste it into the AI assistant of your choice. The more precise your details, the better the result.
Tips for better results
- Specify the framework and ORM library
- Mention the authentication method
- Ask for a Postman collection for testing
- Request Docker Compose for the development environment
Suitable open models
The selection names current open models as a starting point for your own tests. It is not a measurement for this template.
Keywords: #rest-api #backend #endpoints #crud