mirror of
https://github.com/scratchfoundation/scratchjr-website.git
synced 2025-07-23 12:39:07 -04:00
23 lines
421 B
JavaScript
23 lines
421 B
JavaScript
|
/**
|
||
|
* Constructor
|
||
|
*/
|
||
|
function Handler (route) {
|
||
|
// Handle redirects
|
||
|
if (route.redirect) {
|
||
|
return (req, res) => { res.redirect(route.redirect); };
|
||
|
}
|
||
|
|
||
|
var 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);
|
||
|
};
|