Middleware should be allowed to declare parameters that get merged with route-level parameters.
For example, if there's an authentication middleware that relies on a property called access_token being present in the JSON body, it should be able to declare this directly on itself and receive the parsed value.
Alternatives:
await req.clone().json() (.clone() is necessary to avoid consuming the body). Simple but untyped, adds overhead, and dependent properties will not propagate to codegen.
parse request input, run user middleware, then run internal request validation middleware. Requires auth dependencies to be declared at the route level rather than the middleware level for types to propagate correctly.
Middleware should be allowed to declare parameters that get merged with route-level parameters.
For example, if there's an authentication middleware that relies on a property called
access_token
being present in the JSON body, it should be able to declare this directly on itself and receive the parsed value.Alternatives:
await req.clone().json()
(.clone()
is necessary to avoid consuming the body). Simple but untyped, adds overhead, and dependent properties will not propagate to codegen.