Closed
Description
Let's assume an application is defined as following, instantiating several routes that need different middlewares (one for the application endpoints, the other for the admin endpoints):
useExpressServer(application, {
routePrefix: '/app',
controllers: [__dirname + '/app/controllers/**/*.ts'],
middlewares: [AppMiddleware1, AppMiddleware2]
});
useExpressServer(application, {
routePrefix: '/admin',
controllers: [__dirname + '/admin/controllers/**/*.ts'],
middlewares: [AdminMiddleware1]
});
When doing so, the middlewares are executed globally and not scoped to the controllers attached to the route. If another route is defined, here is what happens:
- when calling an url under
/app
:AppMiddleware1
,AppMiddleware2
are executed - when calling an url under
/admin
:AppMiddleware1
,AppMiddleware2
andAdminMiddleware1
are executed
Controllers being correctly attached to a given route, I think middlewares should be doing the same, but from my recent discoveries, it seems this is not properly supported.