REST API Endpoint Builder
Added Apr 1, 2026
About This Prompt
Building robust API endpoints involves much more than writing a route handler. This prompt generates the full stack of an endpoint including validation, error handling, authentication, and documentation layers. The clean architecture separation means you get maintainable code with proper separation of concerns from the start. The included Swagger annotations save you the tedious step of writing API documentation after the fact. This is especially valuable for backend developers starting new microservices or adding endpoints to existing APIs who want consistent, well-structured code.
Variables to Customize
[ENDPOINT_PURPOSE]
What the endpoint does
Example: managing user subscription plans
[FRAMEWORK]
Backend framework to use
Example: Express.js with TypeScript
[HTTP_METHODS]
Which HTTP methods to implement
Example: GET, POST, PUT, DELETE
[ROUTE_PATH]
The URL path for the endpoint
Example: /api/v1/subscriptions
[VALIDATION_LIBRARY]
Validation tool to use
Example: Zod
Tips for Best Results
- Specify your database ORM if you want the data access layer to match your stack
- Add authentication method details for more accurate middleware code
- Request integration tests as a follow-up prompt
Example Output
// subscriptions.controller.ts
import { Router, Request, Response, NextFunction } from 'express';
import { SubscriptionService } from './subscriptions.service';
import { CreateSubscriptionSchema, UpdateSubscriptionSchema } from './subscriptions.validation';
import { authenticate } from '../middleware/auth';
import { rateLimit } from '../middleware/rateLimit';
/**
* @swagger
* /api/v1/subscriptions:
* get:
* summary: List all subscriptions for the authenticated user
*/