fix: Global middlewares are not used if route prefix doesn't start with a slash ("/")
michaelseibt opened this issue · 0 comments
michaelseibt commented
Description
Introducing route prefix scoping for global middlewares created a convention that config.routePrefix needs to start with a slash ("/"), otherwise global middlewares will not be applied.
Let's assume an application is defined as following:
useExpressServer(application, {
routePrefix: 'app',
controllers: [...],
middlewares: [AppMiddleware1, AppMiddleware2]
});
When doing so, none of the middlewares are executed globally for any possible route.
If the routePrefix is having a leading slash, this would work properly:
useExpressServer(application, {
routePrefix: '/app', // <---
controllers: [...],
middlewares: [AppMiddleware1, AppMiddleware2]
});
Expected behavior
Values of routePrefix are either rejected with an error if they don't start with a slash, or the ExpressDriver normalizes this and adds the slash if needed.
Actual behavior
Global middlewares are not used (registered, but use is not called) at all.