let urls = {}; class Url { constructor(url, view, name) { this.url = url; this.view = view; this.name = name; } } function getUrl(name) { return urls[name].url; } module.exports = function(req, res, next) { res.locals.getUrl = getUrl; return next(); } module.exports.getUrl = getUrl; module.exports.url = function(url, viewName, urlName) { let ret = new Url(url, viewName, urlName); urls[urlName] = ret; return ret; }