Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/henriquecustodia/anakin
- Owner: henriquecustodia
- License: mit
- Created: 2016-07-01T12:17:15.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-11-09T00:23:02.000Z (about 8 years ago)
- Last Synced: 2024-10-11T18:49:30.742Z (3 months ago)
- Topics: dependency-injection, es6, mapping, nodejs
- Language: JavaScript
- Size: 37.1 KB
- Stars: 7
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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!