Skip to content

Commit

Permalink
issue/#632
Browse files Browse the repository at this point in the history
desc: update application.js to allow the use of express middleware by plugins
  • Loading branch information
finbartracey1 committed Apr 14, 2015
1 parent f6a92f2 commit d3a4768
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 801 deletions.
34 changes: 31 additions & 3 deletions lib/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ Origin.prototype.createServer = function (options, cb) {
server.use(express.urlencoded());
server.use(express.methodOverride());
server.use(express.static(path.join(require('./configuration').serverRoot, 'frontend', 'src')));

server.use(server.router);
return cb(null, server);
}
Expand Down Expand Up @@ -278,12 +279,40 @@ Origin.prototype.createServer = function (options, cb) {
requestDomain.on('error', next);
requestDomain.run(next);
});




server.use(auth.initialize());
server.use(auth.session());
server.use(express.static(path.join(app.configuration.serverRoot, 'frontend', 'src')));
server.use(permissions.policyChecker());
server.use(server.router);
server.use(app.clientErrorHandler());
// loop through the plugins for middleware
var pluginManager = pluginmanager.getManager();
var plugins = pluginManager.getPlugins();
var plugin;
async.forEach(Object.keys(plugins), function (directory, cbOuter){
async.forEach(Object.keys(plugins[directory]), function (name, cb){
try {
var Plugin = require(plugins[directory][name].fullPath);
plugin = new Plugin();
if ('function' == typeof plugin.getMiddleware){
plugin.getMiddleware(server,function(callback){
callback();
});
}
cb();
} catch (err) {
return cb(err);
}

}, function(err) {
cbOuter()
});
}, function(err) {
server.use(server.router);
server.use(app.clientErrorHandler());
});
});

server.configure('development', function () {
Expand Down Expand Up @@ -436,7 +465,6 @@ Origin.prototype.run = function () {
this.preloadModule('usermanager', require('./usermanager'));
this.preloadModule('tenantmanager', require('./tenantmanager'));
this.preloadModule('rolemanager', require('./rolemanager'));
this.preloadModule('productmanager', require('./productmanager'));
this.preload();
};

Expand Down
23 changes: 0 additions & 23 deletions lib/dml/schema/system/product.schema

This file was deleted.

Loading

0 comments on commit d3a4768

Please sign in to comment.