Manage the configuration of your Nodejs application with multiple environments and custom preferences, utilizing Configuru in CI and development as well!
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.
- 😌 Tailored for multi-developer comfort
- ✨ Cast and transforms inputs to correct type
- 💙 Typescript friendly
- 💪 Designed for multi-environment apps
- 🙈 Anonymized configuration for logger
- 💬 JSONC support
- Install
npm install configuru- Create
.env.jsoncin root of your project, add defaults or placeholders.
-
(optional) As a developer (or environment), create a custom override file (e.g.
~/.env/my-project.jsonc) and save the path in yourCFG_JSON_PATH. -
Create a configuration module (e.g.
config.ts)
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'),
},
})- Use your configuration params throughout your app
import config from './config' // e.g. { server: { port: 3000 } }
console.log(config.server.port) // 3000config- Simple JSON config loader using NODE_ENVdotenv- Load your configuration file to process.ENVcosmiconfig- Traverse your filesystem to load find your lost configuration fileconfigstore- KV storage for configurationfiggy-pudding- Config object builder / storage
Know other popular projects that solve the same issue? Open a PR to help people find what they need!
This project is licensed under MIT.
{ // HTTP server "SERVER_PORT": 3000 // port the server will be listening on }