api-route-endpoint
SKILL.md
API Route/Endpoint Skill
Follow existing Hono patterns in apps/api when creating or updating endpoints.
Workflow
- Identify the feature folder under
apps/api/src/routesand create or update the three files:routes/<feature>/<feature>.index.ts(route wiring)routes/<feature>/<feature>.handler.ts(handlers)routes/<feature>/<feature>.schema.ts(Zod schemas)
- Use
createRouter()for route modules andcreateHandlers()for handlers. - Use
validate()fromapps/api/src/lib/validator.tswith Zod schemas. - Use
initializePrisma(c.env.DATABASE_URL)for database access. - Return JSON with the standard response structure (see references).
- Wire middleware for auth/roles where needed.
- Register the route in
apps/api/src/routes/index.tsif it is a new top-level group.
Required patterns
- Route wiring: use
.get,.post,.put,.deletewith spread handler arrays:route.get('/', ...getItems). - Validation:
validate('param' | 'query' | 'json', schema)as the first handlers increateHandlers. - Handler response: return
c.json({ meta: { code, message }, data: { ... } }, code). - Errors: map Prisma errors to status codes where appropriate; fall through to app error handler.
Middleware
- Use
requireAuthfor authenticated routes. - Use
requireAdminRolefor admin-only routes.
Response structure
- Always return
{ meta: { code, message }, data: { ... } }. - For errors with no payload, return
data: {}.
References
- See
references/api-route-patterns.mdfor concrete file layouts, schema patterns, and response examples.
Weekly Installs
3
Repository
rnldsalili/ai-skillsFirst Seen
Feb 5, 2026
Security Audits
Installed on
opencode3
gemini-cli3
replit3
antigravity3
claude-code3
github-copilot3