mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-23 07:38:07 -05:00
24 lines
428 B
JavaScript
24 lines
428 B
JavaScript
/*
|
|
* Constructor
|
|
*/
|
|
const Handler = function (route) {
|
|
// Handle redirects
|
|
if (route.redirect) {
|
|
return (req, res) => {
|
|
res.redirect(route.redirect);
|
|
};
|
|
}
|
|
|
|
const url = `/${route.name}.html`;
|
|
return function (req, res, next) {
|
|
req.url = url;
|
|
next();
|
|
};
|
|
};
|
|
|
|
/*
|
|
* Export a new instance
|
|
*/
|
|
module.exports = function (route) {
|
|
return new Handler(route);
|
|
};
|