Skip to content

Commit

Permalink
pencilblue#1210 Fixes issue where middleware is not registered before…
Browse files Browse the repository at this point in the history
… plugins are initialized
  • Loading branch information
brianhyder committed Feb 1, 2017
1 parent 23ff123 commit 2999205
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions pencilblue.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 = {
Expand Down

0 comments on commit 2999205

Please sign in to comment.