# @hellroot/config

> NodeJS application configuration

Latest version **1.1.1** (published 2019-03-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install @hellroot/config
pnpm add @hellroot/config
yarn add @hellroot/config
bun add @hellroot/config
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2019-03-23 |
| First published | 2019-03-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=10 |
| Dependencies | 1 |
| Unpacked size | 5.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | evgenymarkov |
| Keywords | config |

## Links

- npm: https://www.npmjs.com/package/@hellroot/config
- Repository: https://github.com/hellroot/config
- Homepage: https://github.com/hellroot/config#readme
- Issues: https://github.com/hellroot/config/issues
- npm.io page: https://npm.io/package/@hellroot/config

## Dependencies (1)

- [merge-options](https://npm.io/package/merge-options.md) 1.0.1

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 1.1.1 (latest) — 2019-03-23
- 1.0.0 — 2019-03-21

## README

# @hellroot/config

[![npm](https://img.shields.io/npm/v/@hellroot/config.svg)](https://www.npmjs.com/package/@hellroot/config)
[![dependencies status](https://img.shields.io/david/hellroot/config.svg)](https://david-dm.org/hellroot/config)
[![dev dependencies status](https://img.shields.io/david/dev/hellroot/config.svg)](https://david-dm.org/hellroot/config?type=dev)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)

NodeJS application configuration library. It loads your configs as NodeJS modules, not JSONs.

## Quick Start

Install package:

```bash
npm install @hellroot/config
```

Create `config` directory:

```
project/
  config/
    default.js
    local.js
    development.js
    testing.js
    production.js
```

Import library and use resulting object defined in default export:

```javascript
import config from '@hellroot/config';

console.log(config);
```

Define `NODE_ENV` and run script:

```javascript
NODE_ENV=development node index.js
```

`config` object will include settings from `config/default.js`, `config/development.js` and `config/local.js`.
If there is a conflict of keys, the objects will be expanded, arrays and primitives will be overridden.

## Example

`default.js`

```javascript
const config = {
  logger: {
    level: 'info'
  },

  server: {
    port: 80,
    ips: ['127.0.0.1']
  }
};

module.exports = config;
```

`development.js`

```javascript
const config = {
  backend: {
    baseUrl: 'https://dev-api.weather.yandex.ru/v1/'
  },

  static: {
    baseUrl: '/static'
  }
};

module.exports = config;
```

`local.js`

```javascript
const config = {
  backend: {
    baseUrl: 'http://127.0.0.1:8090/v1/'
  },

  server: {
    port: 8080,
    ips: ['127.0.0.1', '192.168.1.69']
  }
};

module.exports = config;
```

Resulting object:

```javascript
const config = {
  backend: {
    baseUrl: 'http://127.0.0.1:8090/v1/'
  },

  logger: {
    level: 'info'
  },

  server: {
    port: 8080,
    ips: ['127.0.0.1', '192.168.1.69']
  },

  static: {
    baseUrl: '/static'
  }
};
```

## TypeScript integration

You can use this module in TypeScript projects without pain. See `example` directory.

![VSCode autocomplete](./images/autocomplete.png)

One caveat: you will have to describe your configuration manually.

---
_Source: https://npm.io/package/@hellroot/config · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
