Cursor prompt
Scaffold REST API with Auth
Build a production-ready Express or Next.js API with JWT authentication, rate limiting, input validation, and structured error handling.
You are a senior backend engineer. Scaffold a REST API with the following specification. ## Project: {{project_name}} ## Framework: {{framework}} ## Database: {{database}} ### Authentication Requirements - JWT-based auth with access tokens (15 min) and refresh tokens (7 days) - Refresh token rotation with secure httpOnly cookie storage - Token blacklisting on logout using Redis - Middleware to protect routes by role: {{roles}} ### Rate Limiting - Sliding window algorithm using Redis - Per-IP: 100 requests/15min on public routes - Per-user: 1000 requests/hour on authenticated routes - Return 429 with Retry-After header on limit exceeded ### Input Validation - Use zod schemas for all request body, query params, and path params - Sanitize all string inputs to prevent XSS - Return structured validation errors: { field, message, code } ### Error Handling - Global error handler classifying errors: validation, auth, not-found, server - Structured errors: { error: { code, message, details } } - Log all 5xx errors with full request context - Never expose stack traces to clients in production ### Routes to Implement {{routes}} ### Output Format 1. Directory tree 2. package.json with all dependencies and scripts 3. Complete implementation of each file 4. .env.example with all required variables 5. README with setup and testing instructions
Fill in: {{project_name}}, {{framework}}, {{database}}, {{roles}}, {{routes}}. In Loopy you fill these in a form and copy the finished prompt in one click.
More coding prompts
- CursorAdd File Upload with Cloud StorageMulti-file upload with type checking, size limits, virus scanning, cloud storage, and progress tracking.
- CursorAdd Redis Caching LayerCache-aside Redis caching with typed get/set helpers, TTL management, pattern-based invalidation, and monitoring.
- CursorAdd Stripe Payment IntegrationComplete Stripe checkout, webhooks, subscription management, and billing portal with idempotent webhook handling.
- LovableBooking and Scheduling SystemCalendar-based booking with availability management, confirmations, reminders, and payment collection.
- CursorBuild Admin Dashboard with CRUDData table with server-side CRUD, column sorting and filtering, bulk actions, and role-protected admin panel.
- CursorBuild Data Export FeatureExport large datasets to CSV or Excel with streaming for memory efficiency, background jobs, and signed download links.

