route-decorators icon indicating copy to clipboard operation
route-decorators copied to clipboard

Allow route decorators to receive array of middlewares as param

Open vunguyenhung opened this issue 4 years ago • 2 comments

Sometimes we need to define a set of middlewares to present a functionality. For example, useAuth middleware can be composed of [useJWT(), useMongoDB(), useUser()].

This PR is to allow route decorators to be easier to work within those cases.

vunguyenhung avatar Sep 08 '19 08:09 vunguyenhung

Not sure I'm a fan of this. If it were me, I rather write something like below to be more explicit.

@post('url', ...middlewareGroup, anotherMiddleware)

buunguyen avatar Sep 08 '19 17:09 buunguyen

Yeah, I agree. It makes sense to explicitly use the middleware group, I'm actually using that on my current codebase.

My problem is it quickly became nuisance when we started to use that everywhere (e.g. we must remember to put ... operator) and it puts lots of noise around the codebase

vunguyenhung avatar Sep 15 '19 08:09 vunguyenhung