https://github.com/jakzo/composable-config
Composable app configuration for Node and browser with reading, conversion, validation and type support built-in.
https://github.com/jakzo/composable-config
configuration typescript
Last synced: 3 months ago
JSON representation
Composable app configuration for Node and browser with reading, conversion, validation and type support built-in.
- Host: GitHub
- URL: https://github.com/jakzo/composable-config
- Owner: jakzo
- License: mit
- Created: 2018-10-14T14:43:23.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-10-16T02:42:55.000Z (over 6 years ago)
- Last Synced: 2025-01-13T20:14:34.577Z (5 months ago)
- Topics: configuration, typescript
- Language: TypeScript
- Homepage:
- Size: 276 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Composable Config
_Composable app configuration with loading, conversion, validation and type support built-in._
- [API Reference](docs/api.md)
- [IO Types](docs/io.md)
- [Loaders](docs/loaders.md)
- [Common Patterns](docs/patterns.md)
- [TypeScript](docs/typescript.md)## Quick Start
```sh
npm i composable-config
``````js
import { createConfig, buildConfig } from 'composable-config';
import * as ct from 'composable-config/io';
import envLoader from 'composable-config/loaders/env';const dbConfig = createConfig({
tableName: ct.string,
});const serverConfig = createConfig({
host: {
_: ct.string,
default: '127.0.0.1',
},
port: {
_: ct.Port,
default: 8080,
env: 'SERVER_PORT',
},
});const appConfig = createConfig({
server: serverConfig,
db: dbConfig,
});const config = buildConfig({
config: appConfig,
loaders: [envLoader()],
defaults: {
db: {
tableName: 'xyz',
},
},
});assert(process.env['SERVER_PORT']).equals('1234');
assert(config).equals({
db: {
tableName: 'xyz',
},
server: {
host: '127.0.0.1',
port: 1234,
},
});
```