Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rvanasa/node-xpose
A tiny, flexible dependency injection library for Node.js
https://github.com/rvanasa/node-xpose
Last synced: about 2 months ago
JSON representation
A tiny, flexible dependency injection library for Node.js
- Host: GitHub
- URL: https://github.com/rvanasa/node-xpose
- Owner: rvanasa
- Created: 2019-12-08T21:44:10.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-06-10T19:21:25.000Z (over 3 years ago)
- Last Synced: 2024-01-02T01:13:42.296Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 7.81 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# xpose
A tiny, flexible dependency injection library for NodeJS.
## Installation
```sh
$ npm install -S xpose
```## Example usage
#### /index.js
```js
const xpose = require('xpose');const {App} = xpose({
path: 'src/app/**/*.js',
eager: true,
include: [
xpose({
path: 'src/lib/**/*.js',
}),
],
});
```#### /src/app/App.js
```js
module.exports = ({Service}) => {console.log(Service); // 123
}
```#### /src/app/Service.js
```js
module.exports = ({Helper}) => {console.log('Access to helper library:', Helper);
return 123;
}
```#### /src/lib/Helper.js
```js
module.exports = () => {
return {
// Lazy-loaded resource
};
}
```