mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-27 22:49:56 -05:00
9b54ed0689
refs #9192 - Instead of `setupRoutes` function in apps that gets passed a router, there is now a registerRouter function as part of the proxy - Moved towards a route service, which will know about all routes - Using classes to abstract away shared behaviour Notes: - changing the app proxy didn't result in a test failure! - structure of route service is totally new and may change a lot yet
38 lines
1.3 KiB
JavaScript
38 lines
1.3 KiB
JavaScript
var config = require('../../config'),
|
|
utils = require('../../utils'),
|
|
errors = require('../../errors'),
|
|
logging = require('../../logging'),
|
|
i18n = require('../../i18n'),
|
|
middleware = require('./lib/middleware'),
|
|
router = require('./lib/router'),
|
|
registerHelpers = require('./lib/helpers');
|
|
|
|
module.exports = {
|
|
activate: function activate(ghost) {
|
|
var paths;
|
|
|
|
if (utils.url.getSubdir()) {
|
|
paths = utils.url.getSubdir().split('/');
|
|
|
|
if (paths.pop() === config.get('routeKeywords').private) {
|
|
logging.error(new errors.GhostError({
|
|
message: i18n.t('errors.config.urlCannotContainPrivateSubdir.error'),
|
|
context: i18n.t('errors.config.urlCannotContainPrivateSubdir.description'),
|
|
help: i18n.t('errors.config.urlCannotContainPrivateSubdir.help')
|
|
}));
|
|
|
|
// @TODO: why
|
|
process.exit(0);
|
|
}
|
|
}
|
|
|
|
ghost.routeService.registerRouter('/' + config.get('routeKeywords').private + '/', router);
|
|
|
|
registerHelpers(ghost);
|
|
},
|
|
|
|
setupMiddleware: function setupMiddleware(siteApp) {
|
|
siteApp.use(middleware.checkIsPrivate);
|
|
siteApp.use(middleware.filterPrivateRoutes);
|
|
}
|
|
};
|