Usage
Given that you have a directory structure like...
app/models/items.js
app/controllers/items.js
app/middlewares/auth.js
app/index.js
...you can then use it like:
/* app/index.js */ // require fileloader modulevar fileloader = // this inits a load with the basepath set to './app'var load = // load all '.js' from __dirname + '/models'var models = //load all '.js' from __dirname + '/controllers'var controllers = // load all '.js' from __dirname + '/middlewares'var middlewares = // you may then use it like this:modelsitemscontrollersitemsindexrequest responsemiddlewaresauth // or maybe like this
Debug Output
This module uses https://github.com/visionmedia/debug for logging. To controll output use these wildcards:
DEBUG="loadfiles" node index.js#or DEBUG="loadfiles:debug" node index.js