adejs/utils/create-url.js

28 lines
480 B
JavaScript
Raw Normal View History

2017-09-23 11:02:29 +02:00
let urls = {};
2017-09-23 11:39:42 +02:00
class Url {
constructor(url, view, name) {
this.url = url;
this.view = view;
this.name = name;
}
}
function getUrl(name) {
return urls[name].url;
}
2017-09-23 11:02:29 +02:00
module.exports = function(req, res, next) {
2017-09-23 11:39:42 +02:00
res.locals.getUrl = getUrl;
2017-09-23 11:02:29 +02:00
return next();
}
2017-09-23 11:39:42 +02:00
module.exports.getUrl = getUrl;
2017-09-23 11:02:29 +02:00
2017-09-23 11:39:42 +02:00
module.exports.url = function(url, viewName, urlName) {
let ret = new Url(url, viewName, urlName);
2017-09-23 11:02:29 +02:00
urls[urlName] = ret;
return ret;
}