# @seanmcgary/config-composer

> A node module that allows you to build a hierarchical config structure that can source values from the environment.

Latest version **1.0.0** (published 2019-11-02) · ISC license · 0 weekly downloads

## Install

```sh
npm install @seanmcgary/config-composer
pnpm add @seanmcgary/config-composer
yarn add @seanmcgary/config-composer
bun add @seanmcgary/config-composer
```

## 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.0 |
| Published | 2019-11-02 |
| First published | 2019-11-02 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 9.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | smcgary |

## Links

- npm: https://www.npmjs.com/package/@seanmcgary/config-composer
- npm.io page: https://npm.io/package/@seanmcgary/config-composer

## Dependencies (7)

- [tslib](https://npm.io/package/tslib.md) ^1.9.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.10
- [typescript](https://npm.io/package/typescript.md) ^3.6.4
- [@types/node](https://npm.io/package/@types/node.md) ^10.0.2
- [@types/lodash](https://npm.io/package/@types/lodash.md) ^4.14.108
- [@seanmcgary/tsconfig](https://npm.io/package/@seanmcgary/tsconfig.md) ^1.0.0
- [@seanmcgary/tslint-config](https://npm.io/package/@seanmcgary/tslint-config.md) ^1.0.0

## Recent versions

- 1.0.0 (latest) — 2019-11-02

## README

## config-provider

A node module that allows you to build a hierarchical config structure that can source values from the environment.

### Install

```bash
yarn add @seanmcgary/config-provider

# or

npm install --save @seanmcgary/config-provider
```

### Usage

```bash
mkdir -p src/config
```

```typescript
// src/config/index.ts
import { ConfigProvider } from '@seanmcgary/config-provider';

import server, { ServerConfigShape } from './server';

export interface ConfigShape {
	server: ServerConfigShape;
}

const provider = new ConfigProvider<ConfigShape>({
	environmentPrefix: 'MY_SUPER_COOL_APP'
});

provider.addConfig<ServerConfigShape>(server, 'server');

const config = provider.getConfig();
export default config;
```

```typescript
// src/config/server.ts
import { Config, ExtractValueFn } from '@seanmcgary/config-provider';

export interface ServerConfigShape {
	port: number;
}

export default (ExtractValue: ExtractValueFn): Config<ServerConfigShape> => {
	return new Config<ServerConfigShape>({
		port: ExtractValue({
			name: 'port',
			value: 9000
		}).int
	});
}
```

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