API Endpoint Skill
Workflow
For any new or modified endpoint:
- Propose a short plan (method, path, auth, main logic).
- Implement endpoint with validation, auth, and error handling.
- Use consistent response shape across the API.
- Add tests (at least smoke; prefer unit + integration where applicable).
Validation
- Validate request body/query/params (types, required fields, formats).
- Return clear 400 errors with field-level messages when invalid.
- Use project validation library or schema (e.g. Zod, Joi, class-validator).
Authorization
- Enforce auth for protected routes (JWT, session, API key).
- Check permissions/roles where applicable.
- Return 401/403 with consistent error format.