This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

auto-js-loader

1.0.6 • Public • Published

auto-js-loader

Ps. This module is based on "app-config" - https://www.npmjs.com/package/app-config

Loader utility for Node.js to load different set of files in a folder based on working directory.

Use require('auto-js-loader')('DIRECTORY') when "DIRECTORY" is the directory of the files you want to load.

NOTE: The file is loaded only once. If you want to load the file again, you will need to reload the application.

Quick intro to usage

Create the file

/app_root/commons/connection.js

Give the file some content

// Driver for MongoDB
var mongoose = require('mongoose');
 
// Connection properties
mongoose.connect('mongodb://localhost/mydb');
 
// MongoDB connection
var db = mongoose.connection;
db.on('error', console.log('Connection error...'));
db.once('open', function(callback) {
    console.log("MongoDB connected.");
});
 
module.exports = mongoose;

Load the file in your app

var commons = require('auto-js-loader')('commons');
var mongoose = commons.connection;
 
console.log(mongoose.connection.readyState);

Run your app

node app.js

Installation

npm install auto-js-loader

Dependencies

The tool does not depend on any other code. For developers of this tool, Mocha and Should are the only dependencies for running unit tests.

Development

In order to develop this plugin, these steps are required:

  • Clone the git repo by running git clone URL
  • Go to the newly created directory in Terminal
  • Run npm install to download dependencies
  • Run unit tests by npm test

Readme

Keywords

Package Sidebar

Install

npm i auto-js-loader

Weekly Downloads

3

Version

1.0.6

License

MIT

Last publish

Collaborators

  • zearmando