2020-04-23 18:07:55 +02:00
|
|
|
import {Request, Response} from "express";
|
2021-11-20 19:54:59 +01:00
|
|
|
import {route} from "swaf/common/Routing";
|
2021-11-21 17:52:56 +01:00
|
|
|
import Controller from "swaf/Controller";
|
2020-04-23 18:07:55 +02:00
|
|
|
|
|
|
|
export default class HomeController extends Controller {
|
2020-10-05 13:38:03 +02:00
|
|
|
public routes(): void {
|
2020-04-23 18:07:55 +02:00
|
|
|
this.get('/', this.getHome, 'home');
|
|
|
|
this.get('/about', this.getAbout, 'about');
|
2020-09-03 11:46:00 +02:00
|
|
|
this.get('/back', this.goBack, 'about');
|
2020-04-23 18:07:55 +02:00
|
|
|
}
|
|
|
|
|
2020-10-05 13:38:03 +02:00
|
|
|
protected async getHome(req: Request, res: Response): Promise<void> {
|
2020-04-23 18:07:55 +02:00
|
|
|
res.render('home');
|
|
|
|
}
|
|
|
|
|
2020-10-05 13:38:03 +02:00
|
|
|
protected async getAbout(req: Request, res: Response): Promise<void> {
|
2020-04-23 18:07:55 +02:00
|
|
|
res.render('about');
|
|
|
|
}
|
2020-09-03 11:46:00 +02:00
|
|
|
|
|
|
|
/**
|
2020-11-13 10:54:35 +01:00
|
|
|
* This is to test and assert that swaf extended types are available
|
2020-09-03 11:46:00 +02:00
|
|
|
*/
|
2020-10-05 13:38:03 +02:00
|
|
|
protected async goBack(req: Request, res: Response): Promise<void> {
|
2021-11-20 19:54:59 +01:00
|
|
|
res.redirect(req.getPreviousUrl() || route('home'));
|
2020-09-03 11:46:00 +02:00
|
|
|
}
|
2020-10-05 13:38:03 +02:00
|
|
|
}
|