Permalink
Browse files

#1210 Fixes issue where middleware is not registered before plugins a…

…re initialized
  • Loading branch information...
brianhyder committed Feb 1, 2017
1 parent 23ff123 commit 299920576aa56bfb0fb753944aaaa5cc25a4ee6b
Showing with 14 additions and 5 deletions.
  1. +14 −5 pencilblue.js
View
@@ -71,6 +71,7 @@ function PencilBlue(config){
util.wrapTimedTask(this, this.initCommandService, 'initCommandService'),
util.wrapTimedTask(this, this.initSiteMigration, 'initSiteMigration'),
util.wrapTimedTask(this, this.initSessions, 'initSessions'),
util.wrapTimedTask(this, this.initMiddleware, 'initMiddleware'),
util.wrapTimedTask(this, this.initPlugins, 'initPlugins'),
util.wrapTimedTask(this, this.initSites, 'initSites'),
util.wrapTimedTask(this, this.initLibraries, 'initLibraries'),
@@ -133,6 +134,19 @@ function PencilBlue(config){
pb.session.start(cb);
};
/**
* Registers all default middleware
* @method initMiddleware
* @param {function} cb (Error, boolean)
*/
this.initMiddleware = function (cb) {
//register default middleware
pb.Middleware.getAll().forEach(function(middleware) {
pb.Router.addMiddlewareAfterAll(middleware);
});
cb(null, true);
};
/**
* Initializes the installed plugins.
* @static
@@ -220,11 +234,6 @@ function PencilBlue(config){
*/
this.initServer = function(cb){
//register default middleware
pb.Middleware.getAll().forEach(function(middleware) {
pb.Router.addMiddlewareAfterAll(middleware);
});
//build server setup
var self = this;
var context = {

0 comments on commit 2999205

Please sign in to comment.