Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/henriquecustodia/anakin

This Node module maps all application's dependencies and centralizes everything, at only one place
https://github.com/henriquecustodia/anakin

dependency-injection es6 mapping nodejs

Last synced: about 2 months ago
JSON representation

This Node module maps all application's dependencies and centralizes everything, at only one place

Awesome Lists containing this project

README

        






Anakin


This node module maps all application's dependencies and centralizes everything, at only one place.






## Usage
This [example](https://github.com/henriquecustodia/anakin-example) shows how to use Anakin easily :smile:

## How to install
```javascript
npm install --save anakin
```

## Quick start
```javascript
//module/to/get/ module.js
module.exports = `I'm here`;

//app.js
let anakin = require('anakin')({
base: __dirname
});

anakin.map({
something: 'module/to/get/module.js'
});

let something = anakin.get('something');

console.info(something); //I'm here`
```
## API

* `anakin`: (configuration: **Object**): Object

> This function it useful to configurate how to anakin should to work. It returns an Anakin Object, useful to manage application's dependencies.
```javascript
let anakinObject = require('anakin')({
base: { String } // [REQUIRED] This attribute shows to anakin where is the bootstrap file. It receives only path as String. Recommended to use the __dirname value.
singleton: { Boolean } // When it is truthy, Anakin will keep the dependencies on memory. Otherwise, the dependencies will just be a require cache.
});
```

### Anakin Object

* `map` (mapperObj: **Object**): void

> This method maps all dependencies. The dependecy path does not need has a file extension (e.g .js or .json) because this method uses the `require` method internally.
```javascript
anakin.map({
dependencyName: 'module/to/get/module.js'
});
```

* `get` (module: **String**): any

> This method get a dependency was set in mapper object.
```javascript
anakin.get('someDependency');
```

Pull requests are very welcome!