Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Configuration for user-provided middlewares #661

Closed
wants to merge 2 commits into
from
Jump to file or symbol
Failed to load files and symbols.
+7 −1
Split
View
@@ -199,6 +199,11 @@ MojitoServer.prototype._configureAppInstance = function(app, options) {
if (!options.context) {
options.context = {};
}
+ if (!options.midDir) {
+ options.midDir = 'middleware';
+ }
+
+
// all logging that comes from YUI comes from here
// We need to do this early, since creating a Y instance appears to copy
@@ -394,7 +399,7 @@ MojitoServer.prototype._configureAppInstance = function(app, options) {
} else {
// backwards-compatibility: user-provided middleware is
// specified by path
- midPath = libpath.join(options.dir, midName);
+ midPath = libpath.join(options.dir, options.midDir, midName);
//console.log("======== MIDDLEWARE user " + midPath);
midBase = libpath.basename(midPath);
if (0 === midBase.indexOf('mojito-')) {
@@ -404,6 +409,7 @@ MojitoServer.prototype._configureAppInstance = function(app, options) {
midFactory = require(midPath);
app.use(midFactory(midConfig));
} else {
+ // Load user-provided middleware from middleware folder
app.use(require(midPath));
}
}