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:
dswbx
2025-01-09 10:59:48 +01:00
parent 7d3d1e811f
commit 47f48be514
9 changed files with 58 additions and 27 deletions

View File

@@ -6,14 +6,10 @@ export class Controller {
protected middlewares = {
auth,
permission
}
};
protected create({ auth }: { auth?: boolean } = {}): Hono<ServerEnv> {
const server = Controller.createServer();
if (auth !== false) {
server.use(this.middlewares.auth);
}
return server;
protected create(): Hono<ServerEnv> {
return Controller.createServer();
}
static createServer(): Hono<ServerEnv> {
@@ -23,4 +19,4 @@ export class Controller {
getController(): Hono<ServerEnv> {
return this.create();
}
}
}