mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-15 20:17:22 +00:00
Refactor module middleware initialization logic.
Replaced `getMiddleware` with `onServerInit` for streamlined middleware registration. Updated `AppAuth` to automatically register its authentication middleware. Added a test case to verify middleware registration. Removed redundant cookie renewal logic from `AdminController` and made related adjustments across modules.
This commit is contained in:
@@ -212,14 +212,9 @@ export class ModuleManager {
|
||||
this.options.onServerInit(this.server);
|
||||
}
|
||||
|
||||
// @todo: this is a current workaround, controllers must be reworked
|
||||
// optional method for each module to register global middlewares, etc.
|
||||
objectEach(this.modules, (module) => {
|
||||
if ("getMiddleware" in module) {
|
||||
const middleware = module.getMiddleware();
|
||||
if (middleware) {
|
||||
this.server.use(middleware);
|
||||
}
|
||||
}
|
||||
module.onServerInit(this.server);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -550,4 +545,4 @@ export function getDefaultConfig(): ModuleConfigs {
|
||||
});
|
||||
|
||||
return config as any;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user