diff --git a/src/Application.ts b/src/Application.ts index fa6307f..cb7ac7a 100644 --- a/src/Application.ts +++ b/src/Application.ts @@ -251,7 +251,7 @@ export default abstract class Application implements Extendable Registered routes for controller ${controller.constructor.name}`); + log.info(`> Registered routes for controller ${controller.constructor.name} at ${controller.getRoutesPrefix()}`); } handleRouter.use((req: Request) => { diff --git a/src/Controller.ts b/src/Controller.ts index 304b4c5..45107f9 100644 --- a/src/Controller.ts +++ b/src/Controller.ts @@ -75,6 +75,7 @@ export default abstract class Controller { protected use(handler: RequestHandler): void { this.router.use(this.wrap(handler)); + log.info('Installed anonymous middleware on ' + this.getRoutesPrefix()); } protected useMiddleware(...middlewares: MiddlewareType[]): void { @@ -85,6 +86,8 @@ export default abstract class Controller { } else { this.router.use(this.wrap(instance.getRequestHandler())); } + + log.info('Installed ' + middleware.name + ' on ' + this.getRoutesPrefix()); } } diff --git a/src/auth/AuthController.ts b/src/auth/AuthController.ts index 94681ba..113a646 100644 --- a/src/auth/AuthController.ts +++ b/src/auth/AuthController.ts @@ -24,11 +24,9 @@ export default class AuthController extends Controller { next(); }); - this.useMiddleware(RequireGuestMiddleware); - - this.get('/', this.getAuth, 'auth'); - this.post('/login', this.postLogin, 'login'); - this.post('/register', this.postRegister, 'register'); + this.get('/', this.getAuth, 'auth', RequireGuestMiddleware); + this.post('/login', this.postLogin, 'login', RequireGuestMiddleware); + this.post('/register', this.postRegister, 'register', RequireGuestMiddleware); } protected async getAuth(req: Request, res: Response, _next: NextFunction): Promise {