UNPKG

2.16 kBMarkdownView Raw
1# Bijous
2
3
4[![Build Status](https://travis-ci.org/mbrio/bijous.svg?branch=master)](https://travis-ci.org/mbrio/bijous) [![Dependency Status](https://gemnasium.com/mbrio/bijous.svg)](https://gemnasium.com/mbrio/bijous) [![Code Climate](https://codeclimate.com/github/mbrio/bijous/coverage.png)](https://codeclimate.com/github/mbrio/bijous)
5
6[![NPM Status](https://nodei.co/npm/bijous.png?downloads=true)](https://npmjs.org/package/bijous)
7
8An asynchronous module loader for node.js.
9
10## Installation
11
12You can use this node module in your project by executing the following:
13
14```Shell
15npm install bijous
16```
17
18or by saving it to your *package.json* file:
19
20```Shell
21npm install --save bijous
22```
23
24## Testing
25
26```Shell
27npm install && npm test
28```
29
30## Modules
31
32All modules must conform to the rules set forth by [node](http://nodejs.org/api/modules.html) with the caveat that the module **MUST** export a method that receives a `context` argument and `done` argument. The `context` is a reference to the `Bijous` instance loading the module; and `done` is the callback used when the module has completed loading. The first argument to `done` is an error object and should only be supplied when an error has occurred; the second argument is an object that can be later references by the `Bijous` instance property `modules` which collects the results for each of the modules loaded. The `modules` property references the module loaded by it's filename, if we take the following code as an example and assume the code resides in a file called *modules/server/index.js*:
33
34```JavaScript
35var express = require('express');
36
37exports = module.exports = function (context, done) {
38 var app = express();
39
40 done(null, {
41 app: app,
42 express: express
43 });
44};
45```
46
47Then the results from the server module could be accessed via:
48
49```JavaScript
50var app = bijous.modules.server.app;
51app.use(middleware());
52```
53
54## Usage
55
56The following code will load all modules within the `modules` folder.
57
58```JavaScript
59var Bijous = require('bijous');
60var bijous = new Bijous();
61bijous.require();
62```
63
64## License
65
66ICS &copy; 2014 Michael Diolosa &lt;<michael.diolosa@gmail.com>&gt;