diff --git a/lib/express-load.js b/lib/express-load.js index cc3f4f8..c4a511e 100644 --- a/lib/express-load.js +++ b/lib/express-load.js @@ -238,7 +238,17 @@ ExpressLoad.prototype.into = function(instance, done) { next(); }); } else if (typeof mod === 'function') { - mod = mod.call(script, instance); + // Instance it as function or class + try { + mod = mod.call(script, instance); + } catch(e) { + // If the error is a TypeError, try to call it as a class constructor + if (e.name === 'TypeError') { + mod = new mod(instance); + } else { + throw e; + } + } } }