mirror of
https://github.com/scratchfoundation/scratchjr-website.git
synced 2025-07-03 18:30:22 -04:00
Renamed view field in routes to “name” to match scratch-www, not using “view” field because all scratchJr views are name/name.jsx renamed server to dev-server, and app.js to index.js for consistency with www, and to make clear it’s only the way it runs in development. Added html-webpack-plugin
22 lines
421 B
JavaScript
Executable file
22 lines
421 B
JavaScript
Executable file
/**
|
|
* 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);
|
|
};
|