Vylpes / Droplet

MIT License
0 stars 0 forks source link

Change pages so that the methods directly are what are called for the router #28

Open Vylpes opened 1 year ago

Vylpes commented 1 year ago

Current Behaviour

Currently the on get methods are just called and then are where i put the router.get code in:

public OnGet(): void {
    super.router.get('/', UserMiddleware.Authorise, async (req: Request, res: Response, next: NextFunction) => {
        // ...
    });
}

Requested Behaviour

The method should directly take the arguments in and override the method to set it:

constructor(router: Router) {
    super(router, '/view', true); // <-- the string is the path ('/view'), true will be if need to be authorised
}

public async OnGet(req: Request, res: Response, next: NextFunction) {
    // ...
}

The constructor can also take in the path for this page, since it should be the same for all the methods in here.

It can also take in a boolean to determine if it should use the UserMiddleware.Authorise middleware

Vylpes commented 1 year ago

Not sure how well we will be able to do this with middleware. Might need investigation