middleware-design
Installation
SKILL.md
middleware-design Skill
Goal
This skill guides the creation of the request processing pipeline ("The Onion Architecture").
Steps
1. The Standard Pipeline (Order Matters)
- Request ID: Generate
trace_idimmediately. (Before logs). - CORS: Allow/Block origins. (Before processing).
- Body Parser: JSON/Form parsing. (Limit size to prevent DoS).
- Rate Limiter: Token Bucket algorithm. (Stop abuse cheaply).
- Authentication: Verify JWT/Session. (Who is it?).
- Authorization: Check Roles/Scopes. (Can they do it?).
- Validation: Zod/Pydantic schema check. (Is input valid?).
- Controller: Business Logic.
- Error Handler: Catch exceptions, format JSON, scrub sensitive data.