| name | api-endpoint |
| description | Generate Express.js API endpoint with Auth0 JWT middleware, Zod validation, and Swagger docs Use when this capability is needed. |
| metadata | {"author":"cloudtolocalllm-online"} |
Create a new Express.js API endpoint for {{feature}}.
Include:
- Route registration in services/api-backend/routes/
- Auth0 JWT middleware (requireAuth)
- Request validation with Zod schemas
- Winston logging
- Error handling with proper HTTP status codes
- OpenAPI/Swagger documentation comment
Follow existing patterns in services/api-backend/routes/auth.js
Example structure:
import express from 'express';
import { requireAuth } from '../middleware/auth.js';
import { logger } from '../utils/logger.js';
import { z } from 'zod';
const router = express.Router();
const schema = z.object({
});
router.post('/', requireAuth, async (req, res, next) => {
try {
const validated = schema.parse(req.body);
logger.info({ userId: req.auth.payload.sub, action: '{{feature}}' }, '{{feature}} request');
res.json({ success: true });
} catch (error) {
next(error);
}
});
export default router;
Converted and distributed by TomeVault — claim your Tome and manage your conversions.