mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-27 22:49:56 -05:00
87c01c131b
closes https://github.com/TryGhost/Ghost/issues/9674 - with dynamic routing the first collection get's the "index" context attached - the index context signalises the main post listening route (first collection) - this behaviour was present < 1.24 - we have to keep this behaviour
43 lines
810 B
JavaScript
43 lines
810 B
JavaScript
const _ = require('lodash');
|
|
let routes = [];
|
|
let routers = {};
|
|
|
|
module.exports = {
|
|
setRoute(routerName, route) {
|
|
routes.push({route: route, from: routerName});
|
|
},
|
|
|
|
setRouter(name, router) {
|
|
routers[name] = router;
|
|
},
|
|
|
|
getAllRoutes() {
|
|
return _.cloneDeep(routes);
|
|
},
|
|
|
|
getRouter(name) {
|
|
return routers[name];
|
|
},
|
|
|
|
getFirstCollectionRouter() {
|
|
return _.find(routers, (router) => {
|
|
if (router.name === 'CollectionRouter' && router.firstCollection) {
|
|
return router;
|
|
}
|
|
|
|
return false;
|
|
});
|
|
},
|
|
|
|
resetAllRoutes() {
|
|
routes = [];
|
|
},
|
|
|
|
resetAllRouters() {
|
|
_.each(routers, (value) => {
|
|
value.reset();
|
|
});
|
|
|
|
routers = {};
|
|
}
|
|
};
|