Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/restuwahyu13/kraken-node
Dependency injection to register module to global access, you can load each given module from kraken.config.json
https://github.com/restuwahyu13/kraken-node
dependency dependency-injection global-module javascript kinode kraken kraken-node module-loader node-module nodejs npm-module typescript
Last synced: about 1 month ago
JSON representation
Dependency injection to register module to global access, you can load each given module from kraken.config.json
- Host: GitHub
- URL: https://github.com/restuwahyu13/kraken-node
- Owner: restuwahyu13
- License: mit
- Created: 2021-07-25T13:42:54.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-06T12:59:19.000Z (almost 2 years ago)
- Last Synced: 2024-11-08T06:38:20.009Z (about 1 month ago)
- Topics: dependency, dependency-injection, global-module, javascript, kinode, kraken, kraken-node, module-loader, node-module, nodejs, npm-module, typescript
- Language: TypeScript
- Homepage:
- Size: 450 KB
- Stars: 6
- Watchers: 1
- Forks: 2
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-made-by-indonesian - Kraken Node - `Dependency injection to register module to global access, you can load each given module from kraken.config.json` *by [Restu Wahyu Saputra](https://github.com/restuwahyu13)* (K)
- made-in-indonesia - Kraken Node - `Dependency injection to register module to global access, you can load each given module from kraken.config.json` *by [Restu Wahyu Saputra](https://github.com/restuwahyu13)* (K)
README
# Kraken Node
[![Build Status](https://app.travis-ci.com/restuwahyu13/kinode.svg?token=TJCjdtb3tZAkAUnGPRjB&branch=main)](https://app.travis-ci.com/restuwahyu13/kinode) [![Coverage Status](https://coveralls.io/repos/github/restuwahyu13/kraken-node/badge.svg?branch=main)](https://coveralls.io/github/restuwahyu13/kraken-node?branch=main) [![codebeat badge](https://codebeat.co/badges/2a94b9f3-f82c-45c3-9f8e-fb4b13d44812)](https://codebeat.co/projects/github-com-restuwahyu13-kraken-node-main) [![CodeFactor](https://www.codefactor.io/repository/github/restuwahyu13/kraken-node/badge)](https://www.codefactor.io/repository/github/restuwahyu13/kraken-node) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/dc11d2a4ebeb447f9fb67fc8d0479dab)](https://www.codacy.com/gh/restuwahyu13/kraken-node/dashboard?utm_source=github.com&utm_medium=referral&utm_content=restuwahyu13/kraken-node&utm_campaign=Badge_Grade) ![node-current](https://img.shields.io/node/v/kinode?style=flat-square) ![npm](https://img.shields.io/npm/dm/kinode) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://github.com/restuwahyu13/kraken-node/blob/main/CONTRIBUTING.md)
**kinode** is dependency injection to register module to global access, you can load each given module from **kraken.config.json**, without the need to load module using `require` or `import` again in every file, then module can be accessed as a global with very easy and then only register modules to kraken config, which you often the most used in each every file, example module like `axios`, `lodash`, `moment` etc, for browser version check this [kibrow](https://github.com/restuwahyu13/kraken-browser).
- [Kraken Node](#kraken-node)
- [Installation](#installation)
- [Config](#config)
- [Example Usage](#example-usage)
- [Testing](#testing)
- [Bugs](#bugs)
- [Contributing](#contributing)
- [License](#license)## Installation
```bash
$ npm install kinode -S or yarn add kinode -S
```## Config
- #### Kraken config property
+ **name** for to calling module in each every file and default value is to undefined
+ **module** for to register module to global access and default value is to undefined
+ **inject** for to disabled module to global access, if value is set to false and default value is to true- #### Example kraken.config.json
```json
{
"packages": [
{
"name": "$axios",
"module": "axios"
},
{
"name": "$_",
"module": "lodash"
},
{
"name": "$moment",
"module": "moment",
"inject": false
}
]
}
```## Example Usage
+ ##### Example Usage Config Outside Directory
- ##### Example Usage Using CommonJs With JavaScript
```javascript
require('kinode').config()$axios.get('https://jsonplaceholder.typicode.com/users')
.then(res => console.log(res.data))
.catch(err => console.log(err.response.data))
```
```javascript
require('kinode/config')$axios.get('https://jsonplaceholder.typicode.com/users')
.then(res => console.log(res.data))
.catch(err => console.log(err.response.data))
```- ##### Example Usage Using Esm With JavaScript
```javascript
import { config } from 'kinode'
config()$axios.get('https://jsonplaceholder.typicode.com/users')
.then(res => console.log(res.data))
.catch(err => console.log(err.response.data))
```
```javascript
import 'kinode/config'$axios.get('https://jsonplaceholder.typicode.com/users')
.then(res => console.log(res.data))
.catch(err => console.log(err.response.data))
```
- ##### Example Usage With Typescript```typescript
import { config } from 'kinode'
config()global.$axios.get('https://jsonplaceholder.typicode.com/users')
.then(res => console.log(res.data))
.catch(err => console.log(err.response.data))
```
```typescript
import 'kinode/config'global.$axios.get('https://jsonplaceholder.typicode.com/users')
.then(res => console.log(res.data))
.catch(err => console.log(err.response.data))
```+ ##### Example Usage Config Inside Directory
- ##### Example Usage Using CommonJs With JavaScript
```javascript
require('kinode').config({ directory: 'config' })$axios.get('https://jsonplaceholder.typicode.com/users')
.then(res => console.log(res.data))
.catch(err => console.log(err.response.data))
```- ##### Example Usage Using Esm With JavaScript
```javascript
import { config } from 'kinode'
config({ directory: 'config' })$axios.get('https://jsonplaceholder.typicode.com/users')
.then(res => console.log(res.data))
.catch(err => console.log(err.response.data))
```
- ##### Example Usage With Typescript```typescript
import { config } from 'kinode'
config({ directory: 'config' })global.$axios.get('https://jsonplaceholder.typicode.com/users')
.then(res => console.log(res.data))
.catch(err => console.log(err.response.data))
```## Testing
- Testing Via Local
```sh
npm test or make test
```- Testing Via Local And Build
```sh
make build
```- Testing Via Docker
```sh
docker build -t kraken-node or make dkb tag=kraken-node
```## Bugs
For information on bugs related to package libraries, please visit [here](https://github.com/restuwahyu13/kraken-node/issues)
## Contributing
Want to make **kraken-node** more perfect ? Let's contribute and follow the [contribution guide.](https://github.com/restuwahyu13/kraken-node/blob/main/CONTRIBUTING.md)
## License
- [MIT License](https://github.com/restuwahyu13/kraken-node/blob/main/LICENSE.md)