-
Does anyone have an example of wrapping an express middleware for compatibility with nitro/h3? My company exclusively relies on old express middleware that prevent me from writing new code with nitro. I believe defineEventHandlers Would it be something like:
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
It looks a little more involved. From what I see, in express the res object has a bunch of functions on it that would need to be adapted for nitro. Like a |
Beta Was this translation helpful? Give feedback.
-
Hi, export default fromNodeMiddleware((req, res, next) => {
myExpressMiddleware(req, res, next);
}) Or we could even make it simpler. export default fromNodeMiddleware(myExpressMiddleware) |
Beta Was this translation helpful? Give feedback.
-
@peterroe wow! even better! thank you <3 |
Beta Was this translation helpful? Give feedback.
Hi,
H3
is compatible with express middleware. For your case, you can do like this:Or we could even make it simpler.