middie
middie copied to clipboard
Update index.d.ts
excuse me if this is invalid but from reading the examples it seems like async functions are allowed, so the return type should accept a promise?
i've been thrown off from all the synchronous types in Fastify the last couple of days, so perhaps this should be looked over in other parts of the ecosystem too
What examples? Are those on our website?
You really should not use async here, nor in most other middleware, because there is no real error handling for rejecting promises. Nor there is in express or connect etc.
In essence, the types are telling you that what you are doing is essentially unsafe, because it is.
In express v4 I needed to use this one "hack" where you could have async handlers. I think express v5 has native async handler support.
@juliusmarminge Do you want to also tackle the issues raised by mcollina, or can this PR be closed?
Closing due to discussion above re extra work needed, and no activity.