Skip to content

Commit

Permalink
fix: update middleware path handling to include global prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
rsaz committed Nov 26, 2024
1 parent dc4f5a3 commit b7bffc5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/adapter-express/application-express.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,15 @@ export class AppExpress extends ApplicationBase implements Server.IWebServer {
// eslint-disable-next-line no-prototype-builtins
} else if (entry?.hasOwnProperty("path")) {
const { path, middlewares } = entry as MiddlewareConfig;
const pathGlobal = this.globalPrefix + path;
for (const mid of middlewares) {
if (path) {
if (typeof mid === "function") {
app.use(path, mid as express.RequestHandler);
app.use(pathGlobal, mid as express.RequestHandler);
} else {
const middleware = mid as unknown as ExpressoMiddleware;
middleware.use = middleware.use.bind(middleware);
app.use(path, middleware.use);
app.use(pathGlobal, middleware.use);
}
}
}
Expand Down

0 comments on commit b7bffc5

Please sign in to comment.