2016-04-11 08:58:41 -05:00
|
|
|
var config = require('../../config'),
|
2016-09-12 06:53:04 -05:00
|
|
|
utils = require('../../utils'),
|
2016-04-11 08:58:41 -05:00
|
|
|
errors = require('../../errors'),
|
|
|
|
i18n = require('../../i18n'),
|
|
|
|
middleware = require('./lib/middleware'),
|
|
|
|
router = require('./lib/router');
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
activate: function activate() {
|
2016-09-12 06:53:04 -05:00
|
|
|
if (utils.url.getSubdir()) {
|
|
|
|
var paths = utils.url.getSubdir().split('/');
|
2016-04-11 08:58:41 -05:00
|
|
|
|
2016-09-13 10:41:14 -05:00
|
|
|
if (paths.pop() === config.get('routeKeywords').private) {
|
2016-04-11 08:58:41 -05:00
|
|
|
errors.logErrorAndExit(
|
|
|
|
new Error(i18n.t('errors.config.urlCannotContainPrivateSubdir.error')),
|
|
|
|
i18n.t('errors.config.urlCannotContainPrivateSubdir.description'),
|
|
|
|
i18n.t('errors.config.urlCannotContainPrivateSubdir.help')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
setupMiddleware: function setupMiddleware(blogApp) {
|
|
|
|
blogApp.use(middleware.checkIsPrivate);
|
|
|
|
blogApp.use(middleware.filterPrivateRoutes);
|
|
|
|
},
|
|
|
|
|
|
|
|
setupRoutes: function setupRoutes(blogRouter) {
|
2016-09-13 10:41:14 -05:00
|
|
|
blogRouter.use('/' + config.get('routeKeywords').private + '/', router);
|
2016-04-11 08:58:41 -05:00
|
|
|
}
|
|
|
|
};
|