mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-08 12:09:43 +03:00
20 lines
634 B
JavaScript
20 lines
634 B
JavaScript
|
var ParentRouter = require('../route').ParentRouter,
|
||
|
loader = require('./loader'),
|
||
|
channelRouter = require('./router');
|
||
|
|
||
|
/**
|
||
|
* Channels Router
|
||
|
* Parent channels router will load & mount all routes when
|
||
|
* .router() is called. This allows for reloading.
|
||
|
*/
|
||
|
module.exports.router = function channelsRouter() {
|
||
|
var channelsRouter = new ParentRouter('channels');
|
||
|
|
||
|
loader.list().forEach(function (channel) {
|
||
|
// Create a new channelRouter, and mount it onto the parent at the correct route
|
||
|
channelsRouter.mountRouter(channel.route, channelRouter(channel));
|
||
|
});
|
||
|
|
||
|
return channelsRouter.router();
|
||
|
};
|