From 178edd150a7b8d45d5a792684919dee0a08c0dc0 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Thu, 6 Mar 2014 14:09:10 -0500 Subject: [PATCH] moved action:app.load out of webserver; passing in app, mdw, and controllers into action:app.load. now we can create routes dynamically ;) --- src/routes/index.js | 3 ++- src/routes/plugins.js | 18 +++++++++--------- src/webserver.js | 3 --- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/routes/index.js b/src/routes/index.js index 4c039e6f29..1729294169 100644 --- a/src/routes/index.js +++ b/src/routes/index.js @@ -3,8 +3,8 @@ var nconf = require('nconf'), controllers = require('./../controllers'), meta = require('./../meta'), - plugins = require('./../plugins'), + metaRoutes = require('./meta'), apiRoutes = require('./api'), adminRoutes = require('./admin'), @@ -122,6 +122,7 @@ module.exports = function(app, middleware) { app.get('/api/users/search', middleware.checkGlobalPrivacySettings, controllers.users.getUsersForSearch); pluginRoutes(app, middleware, controllers); + plugins.fireHook('action:app.load', app, middleware, controllers); if (process.env.NODE_ENV === 'development') { require('./debug')(app, middleware, controllers); diff --git a/src/routes/plugins.js b/src/routes/plugins.js index 5e0aa23031..2a18138c85 100644 --- a/src/routes/plugins.js +++ b/src/routes/plugins.js @@ -22,7 +22,7 @@ function setupPluginRoutes(app) { /* * TO BE DEPRECATED post 0.4x and replaced with something that isn't as complicated as this... */ - plugins.fireHook('filter:server.create_routes', custom_routes, function(err, custom_routes) { + /*plugins.fireHook('filter:server.create_routes', custom_routes, function(err, custom_routes) { var route, routes = custom_routes.routes; @@ -33,12 +33,12 @@ function setupPluginRoutes(app) { (function(route) { app[routes[route].method || 'get'](routes[route].route, function(req, res) { routes[route].options(req, res, function(options) { - /*app.build_header({ + app.build_header({ req: options.req || req, res: options.res || res }, function (err, header) { //res.send(header + options.content + templates.footer); - });*/ + }); }); }); }(route)); @@ -68,7 +68,7 @@ function setupPluginRoutes(app) { }(route)); } } - }); + });*/ }); } @@ -82,7 +82,7 @@ function setupPluginAdminRoutes(app) { /* * TO BE DEPRECATED post 0.4x and replaced with something that isn't as complicated as this... */ - plugins.fireHook('filter:admin.create_routes', custom_routes, function(err, custom_routes) { + /*plugins.fireHook('filter:admin.create_routes', custom_routes, function(err, custom_routes) { var route, routes = custom_routes.routes; for (route in routes) { @@ -90,9 +90,9 @@ function setupPluginAdminRoutes(app) { (function(route) { app[routes[route].method || 'get']('/admin' + routes[route].route, function(req, res) { routes[route].options(req, res, function(options) { - //Admin.buildHeader(req, res, function (err, header) { - //res.send(header + options.content + templates['admin/footer']); - //}); + Admin.buildHeader(req, res, function (err, header) { + res.send(header + options.content + templates['admin/footer']); + }); }); }); }(route)); @@ -111,7 +111,7 @@ function setupPluginAdminRoutes(app) { }(route)); } } - }); + });*/ }); } diff --git a/src/webserver.js b/src/webserver.js index 1346ce5452..0653cdedb3 100644 --- a/src/webserver.js +++ b/src/webserver.js @@ -11,7 +11,6 @@ var path = require('path'), db = require('./database'), auth = require('./routes/authentication'), meta = require('./meta'), - plugins = require('./plugins'), logger = require('./logger'), middleware = require('./middleware'), routes = require('./routes'); @@ -82,8 +81,6 @@ if(nconf.get('ssl')) { module.exports.server = server; module.exports.init = function () { - plugins.fireHook('action:app.load', app); - server.on("error", function(err){ if (err.code === 'EADDRINUSE') { winston.error('NodeBB address in use, exiting...');