|
|
|
@ -87,18 +87,7 @@ function groupRoutes(app, middleware, controllers) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module.exports = function (app, middleware, callback) {
|
|
|
|
|
var routers = [
|
|
|
|
|
express.Router(), // plugin router
|
|
|
|
|
express.Router(), // main app router
|
|
|
|
|
express.Router(), // auth router
|
|
|
|
|
];
|
|
|
|
|
var pluginRouter = routers[0];
|
|
|
|
|
pluginRouter.render = function () {
|
|
|
|
|
app.render.apply(app, arguments);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var router = routers[1];
|
|
|
|
|
var authRouter = routers[2];
|
|
|
|
|
const router = express.Router();
|
|
|
|
|
|
|
|
|
|
var relativePath = nconf.get('relative_path');
|
|
|
|
|
var ensureLoggedIn = require('connect-ensure-login');
|
|
|
|
@ -111,11 +100,25 @@ module.exports = function (app, middleware, callback) {
|
|
|
|
|
|
|
|
|
|
// handle custom homepage routes
|
|
|
|
|
router.use('/', controllers.home.rewrite);
|
|
|
|
|
pluginRouter.use('/', controllers.home.rewrite);
|
|
|
|
|
|
|
|
|
|
// homepage handled by `action:homepage.get:[route]`
|
|
|
|
|
setupPageRoute(router, '/', middleware, [], controllers.home.pluginHook);
|
|
|
|
|
|
|
|
|
|
async.series([
|
|
|
|
|
async.apply(plugins.reloadRoutes, router),
|
|
|
|
|
async.apply(authRoutes.reloadRoutes, router),
|
|
|
|
|
async.apply(addCoreRoutes, app, router, middleware),
|
|
|
|
|
async.apply(user.addInterstitials),
|
|
|
|
|
function (next) {
|
|
|
|
|
winston.info('Routes added');
|
|
|
|
|
next();
|
|
|
|
|
},
|
|
|
|
|
], function (err) {
|
|
|
|
|
callback(err);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function addCoreRoutes(app, router, middleware, callback) {
|
|
|
|
|
adminRoutes(router, middleware, controllers);
|
|
|
|
|
metaRoutes(router, middleware, controllers);
|
|
|
|
|
apiRoutes(router, middleware, controllers);
|
|
|
|
@ -132,9 +135,8 @@ module.exports = function (app, middleware, callback) {
|
|
|
|
|
userRoutes(router, middleware, controllers);
|
|
|
|
|
groupRoutes(router, middleware, controllers);
|
|
|
|
|
|
|
|
|
|
routers.forEach((router) => {
|
|
|
|
|
app.use(relativePath || '/', router);
|
|
|
|
|
});
|
|
|
|
|
var relativePath = nconf.get('relative_path');
|
|
|
|
|
app.use(relativePath || '/', router);
|
|
|
|
|
|
|
|
|
|
if (process.env.NODE_ENV === 'development') {
|
|
|
|
|
require('./debug')(app, middleware, controllers);
|
|
|
|
@ -184,17 +186,5 @@ module.exports = function (app, middleware, callback) {
|
|
|
|
|
app.use(controllers['404'].handle404);
|
|
|
|
|
app.use(controllers.errors.handleURIErrors);
|
|
|
|
|
app.use(controllers.errors.handleErrors);
|
|
|
|
|
|
|
|
|
|
// Add plugin routes
|
|
|
|
|
async.series([
|
|
|
|
|
async.apply(plugins.reloadRoutes, pluginRouter),
|
|
|
|
|
async.apply(authRoutes.reloadRoutes, authRouter),
|
|
|
|
|
async.apply(user.addInterstitials),
|
|
|
|
|
function (next) {
|
|
|
|
|
winston.info('Routes added');
|
|
|
|
|
next();
|
|
|
|
|
},
|
|
|
|
|
], function (err) {
|
|
|
|
|
callback(err);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
setImmediate(callback);
|
|
|
|
|
}
|
|
|
|
|