Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

configuru

Package Overview
Dependencies
Maintainers
0
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

configuru

Manage the configuration of your Nodejs application with multiple environments and custom preferences, utilizing Configuru in CI and development as well!

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
363
increased by5.22%
Maintainers
0
Weekly downloads
 
Created
Source

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
npm install configuru
  1. Create .env.jsonc in root of your project, add defaults or placeholders.
{
  // HTTP server
  "SERVER_PORT": 3000 // port the server will be listening on
}
  1. (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.

  2. 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'),
  },
})
  1. Use your configuration params throughout your app
import config from './config' // e.g. { server: { port: 3000 } }

console.log(config.server.port) // 3000

Docs

  • Config storage precedence
  • Advanced usage
  • Best practices

See also

  • config - Simple JSON config loader using NODE_ENV
  • dotenv - Load your configuration file to process.ENV
  • cosmiconfig - Traverse your filesystem to load find your lost configuration file
  • configstore - KV storage for configuration
  • figgy-pudding - Config object builder / storage

Know 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.

Keywords

FAQs

Package last updated on 18 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc