scratchjr-website/dev-server/handler.js
chrisgarrity a2125b48c9 Refactoring for deployment
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
2016-09-21 13:02:23 -04:00

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);
};