diff --git a/lib/vhost-sni-server.js b/lib/vhost-sni-server.js index c4059dd..3be38ea 100644 --- a/lib/vhost-sni-server.js +++ b/lib/vhost-sni-server.js @@ -87,6 +87,11 @@ module.exports.create = function (securePort, certsPath, vhostsdir) { console.log('[log] LOADING "' + domaininfo.hostname + '/' + domaininfo.pathname + '"'); getAppContext(domaininfo).then(function (localApp) { + //if (localApp.arity >= 2) { /* connect uses .apply(null, arguments)*/ } + if ('function' !== typeof localApp) { + localApp = getDummyAppContext(null, "[ERROR] no connect-style export from " + domaininfo.dirname); + } + // Note: pathname should NEVER have a leading '/' on its own // we always add it explicitly try { @@ -156,10 +161,12 @@ module.exports.create = function (securePort, certsPath, vhostsdir) { , port: securePort , url: domaininfo.pathname }); + if (!localApp) { - return getDummyAppContext(null, "[ERROR] no app was returned by app.js for " + domaininfo.driname); + localApp = getDummyAppContext(null, "[ERROR] no app was returned by app.js for " + domaininfo.dirname); } } + if (!localApp.then) { localApp = PromiseA.resolve(localApp); } else { @@ -170,8 +177,6 @@ module.exports.create = function (securePort, certsPath, vhostsdir) { } catch(e) { localApp = getDummyAppContext(e, "[ERROR] could not load app.js for " + domaininfo.dirname); localApp = PromiseA.resolve(localApp); - - return localApp; } return localApp;