Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
auto-load-dir
Advanced tools
A simple module to auto load modules from a dir. It was originally intended for loading express routes from routes/
, but it could be used to load models as well.
npm install --save auto-load-dir
Most interaction is done via the Loader
class. As a convinence, a helper method is provided as module.exports, which simply creates a new Loader
with the provided arguments.
var Loader = require('auto-load-dir').Loader;
// Or
var Loader = require('auto-load-dir');
// Later
var routesLoader = new Loader(__dirname + '/routes', [app, express], function(){
// Yay! Routes are loaded.
});
// Even later
var modelLoader = new Loader(__dirname + '/models', function(model){
model.init(mongoose, models);
model.start();
model.blowUpPluto(); // Who knows.
}
dir
is the directory to load all js files in.
args
is an Array of arguments that get passed into module.exports for each module
OR
handler
is a function that gets called with one argument, the already required module.
callback
(optional) gets called with no paramaters if loading is sucessful, or an error if it's not.
PRs are welcome! This was a simple file that I had in a project that needed encapsulating. Please add functionality and open a PR! It uses the AirBnB JavaScript style guide.
git clone https://github.com/ariporad/auto-load-dir
cd auto-load-dir
npm install
grunt test
# (Also avalible is grunt lint)
FAQs
A simple module to auto load modules from a dir.
The npm package auto-load-dir receives a total of 2 weekly downloads. As such, auto-load-dir popularity was classified as not popular.
We found that auto-load-dir demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.