API Endpoint Generator with Express
Create secure, well-documented REST API endpoints using Express.js with proper validation, error handling, and database integration. Ideal for backend developers building robust APIs.
Customize
Your prompt
You are a Senior Backend Developer with expertise in Node.js, Express.js, database design, and API security.
## TASK
Create a complete Express.js API endpoint for {{endpoint-type}} operations with the following specifications:
### ENDPOINT REQUIREMENTS
- Implement {{http-method}} method for {{resource-name}}
- Use {{database-type}} for data persistence
- Include comprehensive input validation
- Add proper authentication and authorization
- Implement error handling with appropriate HTTP status codes
- Include request/response logging
### SECURITY MEASURES
1. **Input Validation**: Sanitize and validate all inputs
2. **Authentication**: JWT or session-based auth
3. **Rate Limiting**: Prevent abuse and DOS attacks
4. **CORS Configuration**: Proper cross-origin settings
5. **Error Handling**: Secure error messages without data leaks
### CODE STRUCTURE
1. **Route Definition**: Express route with middleware
2. **Controller Logic**: Business logic separation
3. **Database Operations**: Optimized queries with error handling
4. **Response Formatting**: Consistent API response structure
5. **Documentation**: JSDoc comments and API documentation
### OUTPUT FORMAT
Provide complete code including:
- Route handler with middleware
- Controller function
- Database model/schema
- Validation schemas
- Error handling middleware
- Usage examples with curl commands
- API documentation snippet
— via PromptShop: https://promptshop.munirabbasi.me/prompts/api-endpoint-generator-with-expressHow to use it
This prompt creates complete backend API endpoints with security best practices. For CRUD operations, pair 'POST/PUT/GET/DELETE' methods with appropriate database types. MongoDB works well for flexible schemas, PostgreSQL for relational data. Always includes authentication, validation, and proper error handling. The generated code follows REST conventions and includes comprehensive documentation.
Tags
Related prompts
WebSocket Server Scaffold Generator
Generate a complete WebSocket server with room management, event handling, authentication, heartbeat monitoring, and reconnection support for real-time applications.
Message Broker Setup Generator
Generate a complete message broker configuration with topic design, producer and consumer code, dead letter handling, and operational setup for RabbitMQ or Kafka.
File Upload and Processing Pipeline
Generate a complete file upload system with multipart handling, virus scanning, image processing, cloud storage integration, and progress tracking for your backend.
API Versioning Strategy Implementer
Generate a complete API versioning system with routing, deprecation handling, version negotiation, migration guides, and backward compatibility strategies for evolving APIs.
Background Job Scheduler Builder
Generate a complete job scheduling system with cron definitions, recurring task management, execution locking, failure recovery, and admin dashboard data for background automation.
GraphQL Schema and Resolver Builder
Generate complete GraphQL schemas with type definitions, queries, mutations, subscriptions, and resolver implementations tailored to your data model and backend framework.