# config-importer

> Import your configuration files from one folder. Any config will change or add variables to a default configuration.

Latest version **1.0.3** (published 2019-10-27) · ISC license · 0 weekly downloads

## Install

```sh
npm install config-importer
pnpm add config-importer
yarn add config-importer
bun add config-importer
```

## 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.0.3 |
| Published | 2019-10-27 |
| First published | 2019-06-23 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Francisco Castel-Branco |
| Maintainers | khor |

## Links

- npm: https://www.npmjs.com/package/config-importer
- Repository: https://gitlab.com/Khorsan/config-importer
- Homepage: https://gitlab.com/Khorsan/config-importer#readme
- Issues: https://gitlab.com/Khorsan/config-importer/issues
- npm.io page: https://npm.io/package/config-importer

## Dependencies (1)

- [nested-object-assign](https://npm.io/package/nested-object-assign.md) ^1.0.3

## Recent versions

- 1.0.3 (latest) — 2019-10-27
- 1.0.2 — 2019-10-13
- 1.0.1 — 2019-06-27
- 1.0.0 — 2019-06-26
- 0.0.2 — 2019-06-23
- 0.0.1 — 2019-06-23

## README

I've made this module in order to allow developers to create applications with the different work stages, such as *production*, *testing*, *development*, etc.

This module allows you to have a **default** configuration file and change its specific values according to your `NODE_ENV` variable.


## How to use

To use this module with the default values, you just need to get the configuration like this:
```javascript
const config = require('config-importer')()
```

If you want to change the options, you need to add options as an argument:
```javascript
const options = {
    path: "configPath"
}

const config = require('config-importer')(options)
```


## Options
You can leave the options empty. The default values are:
```json
{
    "path": "config",   
    "default": "default",
    "debug": false
}
```

+ `path`: represents the directory where your configuration files are stored in relation to your project root directory.
+ `default`: represents the default configuration file name, without the `.json` extension.
+ `debug`: makes this module output debug log (i.e. config directory, thrown exceptions).

## Example

In this scenario, you have your default configuration in `config/default.json` and you are running your application with `NODE_ENV=dev npm start`.

This module overwrites the values from `default.json` with the ones set on `dev.json`, as shown:

`default.json`
```json
{
    "title": "Application title",
    "mongodb": {
        "uri": "https://productionhost:9999/db",
        "username": "username",
        "password": "password"
    }
}
```

`dev.json`
```json
{
    "mongodb": {
        "uri": "https://devhost:9999/db",
        "extra": "param"
    }
}
```

Then, the configuration on your application should be:
```json
{
    "title": "Application title",
    "mongodb": {
        "uri": "https://devhost:9999/db",
        "username": "username",
        "password": "password",
        "extra": "param"
    }
}
```

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