2013-04-09 16:02:36 +00:00
|
|
|
/**
|
|
|
|
* Module dependencies.
|
|
|
|
*/
|
|
|
|
|
|
|
|
var ModuleLoader = require('module-loader');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Export the middleware.
|
|
|
|
*/
|
|
|
|
|
|
|
|
module.exports = configure;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load application modules based on the current directories configuration files.
|
|
|
|
*/
|
|
|
|
|
|
|
|
function configure(root) {
|
|
|
|
var moduleLoader = ModuleLoader.create(root || '.');
|
|
|
|
|
2013-04-10 17:55:13 +00:00
|
|
|
process.__asteroidCache = {};
|
|
|
|
|
2013-04-09 16:02:36 +00:00
|
|
|
return function configureMiddleware(req, res, next) {
|
|
|
|
req.modules = res.modules = moduleLoader;
|
|
|
|
moduleLoader.load(next);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|