Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/AckeeCZ/configuru
Multiple-environment configuration manager
https://github.com/AckeeCZ/configuru
backend builder config configuration dot-env env environment hacktoberfest loader node nodejs parser preferences process-env setup variable
Last synced: 7 days ago
JSON representation
Multiple-environment configuration manager
- Host: GitHub
- URL: https://github.com/AckeeCZ/configuru
- Owner: AckeeCZ
- License: mit
- Created: 2019-04-10T13:16:49.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-08-13T09:14:20.000Z (3 months ago)
- Last Synced: 2024-11-05T23:06:32.424Z (8 days ago)
- Topics: backend, builder, config, configuration, dot-env, env, environment, hacktoberfest, loader, node, nodejs, parser, preferences, process-env, setup, variable
- Language: TypeScript
- Homepage:
- Size: 136 KB
- Stars: 11
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: .github/contributing.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
![](logo.png)
Configuru
Manage the configuration of your Nodejs application with multiple environments and custom preferences, utilizing Configuru in CI and development as well!
## Features
Configuru is a library for configuration management. Merge default project configuration with your user config, you can link yo your project. Atop of that, override your configuration with system environment variables.
- :relieved: Tailored for multi-developer comfort
- :sparkles: Cast and transforms inputs to correct type
- :blue_heart: Typescript friendly
- :muscle: Designed for multi-environment apps
- :see_no_evil: Anonymized configuration for logger
- 💬 JSONC support## Getting started
1. Install
```bash
npm install configuru
```2. Create `.env.jsonc` in root of your project, add defaults or placeholders.
```jsonc
{
// HTTP server
"SERVER_PORT": 3000 // port the server will be listening on
}
```3. _(optional)_ As a developer (or environment), create a custom override file (e.g. `~/.env/my-project.jsonc`) and save the path in your `CFG_JSON_PATH`.
4. Create a configuration module (e.g. `config.ts`)
```typescript
import { createLoader, values } from 'configuru'// create loader that cascades overrides and creates a config storage
const loader = createLoader()// Pass configuration schema to `values` transformer to get configuration
export default values({
server: {
// use loader accessors, place them in custom structure
// loader parses correct type from store
port: loader.number('SERVER_PORT'),
},
})
```5. Use your configuration params throughout your app
```typescript
import config from './config' // e.g. { server: { port: 3000 } }console.log(config.server.port) // 3000
```## Docs
- [Config storage precedence](./wiki/storage-precedence.md)
- [Advanced usage](./wiki/advanced-usage.md)
- [Best practices](./wiki/best-practices.md)## See also
- [`config`](https://www.npmjs.com/package/config) - Simple JSON config loader using NODE_ENV
- [`dotenv`](https://www.npmjs.com/package/dotenv) - Load your configuration file to process.ENV
- [`cosmiconfig`](https://www.npmjs.com/package/cosmiconfig) - Traverse your filesystem to load find your lost configuration file
- [`configstore`](https://www.npmjs.com/package/configstore) - KV storage for configuration
- [`figgy-pudding`](https://www.npmjs.com/package/figgy-pudding) - Config object builder / storageKnow other popular projects that solve the same issue? Open a PR to help people find what they need!
## License
This project is licensed under [MIT](./LICENSE).