You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For some APIs, its nice to have the ability to run some pre/post operations on a per-route or per-group basis. For example, you want some public routes, and some protected routes requiring a JWT token. Maybe this can currently be achieved in the Bao.before(), but the DX around it could be improved.
One solution is to allow things like Bao.get() to accept multiple IHandler's.
get(...handlers: IHandler[]){}
Another step up from that would be to implement a multi-router support like Express or Koa does
constapp=newBao();constHelloRouter=newRouter('/hello');HelloRouter.before(logger());HelloRouter.get(protect(),ctx=>ctx.sendText('world'));app.use(HelloRouter);// or app.use('/hello', HelloRouter) if preferred DX
The text was updated successfully, but these errors were encountered:
Both things would be helpful. I miss Express's modular approach to route handlers, being able to define middlewares per route, and being able to use multiple middleware.
For some APIs, its nice to have the ability to run some pre/post operations on a per-route or per-group basis. For example, you want some public routes, and some protected routes requiring a JWT token. Maybe this can currently be achieved in the
Bao.before()
, but the DX around it could be improved.One solution is to allow things like
Bao.get()
to accept multipleIHandler
's.Another step up from that would be to implement a multi-router support like Express or Koa does
The text was updated successfully, but these errors were encountered: