# export-config

> This is a Node module to help developers to export the right configuration to the environment thisthe application is running

Latest version **1.0.5** (published 2024-02-22) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2024-02-22 |
| First published | 2017-02-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=16.14.1 |
| Dependencies | 0 |
| Unpacked size | 6.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | André Almeida |
| Maintainers | andrebot |
| Keywords | Export, config |

## Links

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

## 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.0.5 (latest) — 2024-02-22
- 1.0.4 — 2023-12-01
- 1.0.3 — 2023-06-27
- 1.0.2 — 2023-01-23
- 1.0.1 — 2023-01-22
- 1.0.0 — 2017-02-08

## README

# Export Config
This is a small module to help developers to manage their App's configuration. The idea is to be able to have one config file for each concern/subject in your system.

Organizing your configuration this way you can easily find what you are looking for without searching through different files for each environment. But we should also be able to import seemlessly this configurations in the App, to avoid poluting the code and to not confuse the dev team. It should be easy as `require('./config/database');`.

## Example
```js
// config/database
'use strict';

const exportConfig = require('export-config');

const DatabaseConfig = {
  default: {
    RECONNECT_TRIES: 3,
    RECONNECT_INTERVAL: 1000,
    AUTO_RECONNECT: true,
    BUFFER_MAX_ENTRIES: 0,
    SCHEDULE_TIMEOUT: 7200000
  },
  development: {
    URI: 'mongodb://localhost/dev_db'
  },
  staging: {
    URI: 'mongodb://localhost/test'
  },
  production: {
    URI: 'mongodb://243.123.63.10/prod_db_01',
    RECONNECT_TRIES: 4,
    RECONNECT_INTERVAL: 1500
  }
}

module.exports = exportConfig(DatabaseConfig);
```

```js
// index.js

const DatabaseConfig = require('./config/database');

console.log(DatabaseConfig);
/**
 * If we have not set the process.env.NODE_ENV variable, it will print:
 * {
 *   RECONNECT_TRIES: 3,
 *   RECONNECT_INTERVAL: 1000,
 *   AUTO_RECONNECT: true,
 *   BUFFER_MAX_ENTRIES: 0,
 *   SCHEDULE_TIMEOUT: 7200000,
 *   URI: 'mongodb://localhost/dev_db'
 * }
 *
 * But if we have set the process.env.NODE_ENV to 'production'
 * {
 *   RECONNECT_TRIES: 4,
 *   RECONNECT_INTERVAL: 1500,
 *   AUTO_RECONNECT: true,
 *   BUFFER_MAX_ENTRIES: 0,
 *   SCHEDULE_TIMEOUT: 7200000,
 *   URI: 'mongodb://243.123.63.10/prod_db_01'
 * }
 */
```
This way we can arrange our configuration files as:

```
+-- config
|   +-- mongo.js
|   +-- redis.js
|   +-- ghost.js
|   +-- googleCalendar.js
|   ...
+-- index.js
```
And import each configuration file separetly nicely and seemlessly as `require('./config/mongo.js')`.

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