How to do interleaved middleware #1606
-
With using the current middleware pattern, theres no way to interleave the request handling like traditional middleware - it expects the return value to become "options" for the handler, but that isn't sufficient for resources that need to be cleaned up or managed entirely within the middleware. I'd like these to be express-zod-api middlewares, since they is closer to the handlers. For instance, this pattern is not possible:
Examples: sql clients, opentelemetry span, etc. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
I've never seen such a pattern in express.js , @daniel-white . However, I understand your concern regarding managing resources. Would that work for you? |
Beta Was this translation helpful? Give feedback.
-
Update on this matter: |
Beta Was this translation helpful? Give feedback.
Update on this matter:
https://github.com/RobinTail/express-zod-api?tab=readme-ov-file#options