18 lines
556 B
TypeScript
18 lines
556 B
TypeScript
import {Router} from "express";
|
|
|
|
import ApplicationComponent from "../ApplicationComponent.js";
|
|
|
|
export default class FormHelperComponent extends ApplicationComponent {
|
|
|
|
public async initRoutes(router: Router): Promise<void> {
|
|
router.use((req, res, next) => {
|
|
if (['GET', 'POST'].find(m => m === req.method)) {
|
|
if (typeof req.body === 'object' && Object.keys(req.body).length > 0) {
|
|
req.flash('previousFormData', req.body);
|
|
}
|
|
}
|
|
next();
|
|
});
|
|
}
|
|
}
|