# @quantum-sec/node-config-utils

> Utility for reading config values from files, command line arguments, and environment variables.

Latest version **1.1.0** (published 2024-01-22) · SEE LICENSE IN LICENSE license · 0 weekly downloads

## Install

```sh
npm install @quantum-sec/node-config-utils
pnpm add @quantum-sec/node-config-utils
yarn add @quantum-sec/node-config-utils
bun add @quantum-sec/node-config-utils
```

## 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.1.0 |
| Published | 2024-01-22 |
| First published | 2021-10-26 |
| Weekly downloads | 0 |
| License | SEE LICENSE IN LICENSE |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 30.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Armor Defense Inc. |
| Maintainers | lukiffer, quantum-ci-bot |

## Links

- npm: https://www.npmjs.com/package/@quantum-sec/node-config-utils
- Repository: https://github.com/armor/node-config-utils
- Homepage: https://github.com/armor/node-config-utils#readme
- Issues: https://github.com/armor/node-config-utils/issues
- npm.io page: https://npm.io/package/@quantum-sec/node-config-utils

## Dependencies (2)

- [yargs](https://npm.io/package/yargs.md) ^16.2.0
- [js-yaml](https://npm.io/package/js-yaml.md) ^3.14.1

## Recent versions

- 1.1.0 (latest) — 2024-01-22
- 1.0.0 — 2021-10-26

## README

# node-config-utils

Utility for reading config values from files, command line arguments, and environment variables.

## Installation

```bash
npm install --save @quantum-sec/node-config-utils
```

## Usage

Create a reusable instance of `ConfigService` passing a map of configuration options:

```typescript
// example.config.ts
export const config = new ConfigService({
  'my-option': {
    description: 'An example configuration option',
    required: true,
    alias: 'o',
  },
});

// usage.ts
import { config } from './example.config';

console.log(config['my-option']);
```

This will now populate the `config` object with a key `my-option` taking its value from a CLI argument,
environment variable (as `MY_OPTION`), or from a YAML config file.

### Precedence

When a value is specified in multiple mediums, the following order is observed when determining
precedence (top of list takes highest precedence):

- CLI arguments
- Environment variables
- Configuration file

### Environment Variable Prefix

You can optionally pass an environment variable prefix to the constructor. This is helpful when needing
to avoid collisions.

```typescript
const config = new ConfigService({ /* ... */ }, 'QS');
```

In the above example `QS` would be prefixed to each environment variable name. For example, if you define
a config key `my-option` which would normally search the environment variable `MY_OPTION`, it would
instead search `QS_MY_OPTION`.

### Built-In Options

- `--help` (alias: `-h`) – display the list of available command line arguments
- `--version` (alias: `-v`) – display the version of the application (from package.json)
- `--config` (alias: `-c`) – the path to the configuration file (default: `./config.yaml`)

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