Ghost/core/server/services/route/index.js
Hannah Wolfe 016ee17ebb
Rework route service to prevent circular dependencies (#9229)
refs #9192, refs #9178  

After trying to progress with current implementation, it became clear that the route service can't control the boot sequence, because then we end up with circular dependencies between the route service and the channel service.

The route service now exposes:
-  a siteRouter 
- a way for apps to register routes.
- ParentRouter base class for other modules to use
- the registry

...

- moved the default route setup back to site/routes.js 🙈
- moved the parent channel router back to the channel service (this makes way more sense imo)
- this structure prevents circular dependencies
- split the registry out into it's own thing
- fixed-up various bits of tests and comments
- DEBUG will print a list of routes 🎉
2017-11-09 13:58:22 +00:00

23 lines
794 B
JavaScript

/**
* # Route Service
*
* Note: routes are patterns, not individual URLs, which have either
* subrouters, or controllers mounted on them. There are not that many routes.
*
* The route service is intended to:
* - keep track of the registered routes, and what they have mounted on them
* - provide a way for apps to register routes
* - expose base classes & registry to the rest of Ghost
*/
// This is the main router, that gets extended & mounted /site
module.exports.siteRouter = require('./site-router');
// We expose this via the App Proxy, so that Apps can register routes
module.exports.appRouter = require('./app-router');
// Classes for other parts of Ghost to extend
module.exports.ParentRouter = require('./ParentRouter');
module.exports.registry = require('./registry');