Node.js configuration engine

Related tags

Autocomplete cofman
Overview

Cofman

Coverage Status Build Status

Node.js configuration engine

const { Cofman, FileSource, EnvSourc, ObjectSource } = require("@umbrellio/cofman")

const instance = new Cofman()

instance.use(new FileSource({ path: "/path/to/file.yml" }))
instance.use(new FileSource({ path: "/path/to/file.json" }))
instance.use(new ObjectSource({ custom: "value" }))
instance.use(new EnvSource({ prefix: "APP" }))

const config = instance.parse()

config.get("database.url")

Install

$ yarn add @umbrellio/cofman

Usage

const instance = new Cofman()

Methods

  • .use(source) – setup a config source (see sources docs)
  • .parse() – parse sources and return Config object

Config object

Methods

  • .get(key: string, default: any) – returns a value by corresponding key or default value

    key can be nested by using . . For example – database.password

  • .asObject() – returns config as a plain object

Sources

Cofman supports multiple sources for getting values in different ways.

EnvSource

Get values from env variables. All keys becomes camelCase.

new EnvSource(options)

Options

  • prefix: string (optional, default: "") – prefix for filtering env vars eg. if prefix: "APP" cofman will only get vars starts with APP_ (APP_DATABASE_URL, APP_NAME, etc.)
  • tryParse: boolean (optional, default: true) – try to parse value as a json
  • nestingDelitemer: string (optional, default: __) – delimeter for getting nesting values eg. SOME__NESTING_VALUE=1 becomes some: { nestingValue: 1 }

FileSource

Reads config from json and yaml files.

new FileSource(options)

Options

  • path: string (required) – path to config file
  • parser: Parser (optional, determinites by file extension) – parser to use for this file content
  • failMissing: boolean (optional, default: false) – fail when file missing or not

You can use custom file parsers using following interface:

interface Parser {
  extensions: string[] // supported file extensions

  parse(content: string): Object // takes file content and returns parsed object
}

ObjectSource

Just your custom object

new ObjectSource(object)

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/umbrellio/cofman.

License

Released under MIT License.

Authors

Created by Aleksei Bespalov.

Supported by Umbrellio
You might also like...

a simple zero-configuration command-line http server

a simple zero-configuration command-line http server

http-server: a command-line http server http-server is a simple, zero-configuration command-line http server. It is powerful enough for production usa

Jan 4, 2023

A Browserslist configuration which reflects standardized-audio-context support.

@generative-music/browserslist-config-standardized-audio-context A Browserslist configuration which reflects standardized-audio-context support. This

Oct 28, 2022

The Ghost configuration for the blog of Stefan Kühnel.

Railway Ghost Starter The Ghost configuration for a blog hosted on Railway with an external MySQL database. Found a bug? 💁‍♀️ Thanks for letting me k

Apr 9, 2022

A custom action for setting GitHub Workflow environment variables with YAML configuration files.

yaml-env-action - A custom action for setting GitHub Workflow environment variables with YAML configuration files. Introduction yaml-env-action is a c

Dec 13, 2022

🛠 Nodejs configuration the easy way.

@elite-libs/auto-config Intro A Unified Config & Arguments Library for Node.js! Featuring support for environment variables, command line arguments, a

May 17, 2022

🎡 Generate a random number, a list of them, or a generator with optional configuration

random_number Generate a random number, a list of them, or a generator with optional configuration Usage import randomNumber from "https://deno.land/x

Aug 7, 2022

This package includes some opinionated configuration for ESLint.

eslint-config-float This package includes some opinionated configuration for ESLint, used at Float and friends. Installation You can install and use t

Jan 7, 2022

This "To-do-list" app is a simple web application that displays a list of task and allows you to add and remove task from that list. it is built with the latest technology namely; JavaScript with webpack Configuration.

This

To-do-list "To-do-list" is a simple web application that displays a list of task and allows you to add and remove task from that list. Built With HTML

Nov 21, 2022

Automatically configure Vitest from your SvelteKit configuration.

vitest-svelte-kit Automatically configure Vitest from your SvelteKit configuration. Getting Started Installing In an existing SvelteKit project, run t

Dec 30, 2022

A template to create a React Library. Zero configuration, just use!

React lib template 📦 A simple React lib template based on Parcel and Jest. Usage use this template for your next React lib, modify it and run npm run

Aug 22, 2022

This package includes the sensible ESLint configuration used by our team

TypeScript + Prettier ESLint configuration for CasterlyApp team (and others)

Jan 26, 2022

Shared eslint configuration for Strapi v4 plugins & applications.

This package is currently under development and should be consider ALPHA in terms of state. I/We are currently accepting contributions and/or dedicated contributors to help develop and maintain this package.

Oct 28, 2022

An ESLint shareable configuration that used in our projects.

eslint-config An ESLint shareable configuration that used in our projects. Install npm install -D @rahagia/eslint-config or with yarn yarn add -D @rah

Apr 18, 2022

Used for creating a out-of-the-box template without additional configuration.

ou Used for creating a out-of-the-box template without additional configuration. Templates Vue3 Lite Template Used for some simple web app Vue3 + Vite

Jul 17, 2022

URL query encoder/decoder with a user configuration

@lfgroup/query-coder URL query coder/decoder with configurable user pattern. It provides the most comfortable experience for encoding and decoding com

Jul 14, 2022

This is a library that makes it possible to change the configuration values of the Remix compiler (esbuild).

💽 remix-esbuild-override ⚠️ While I believe you will most likely get a lot of benefit from using this library, it can sometimes destroy your product.

Dec 22, 2022

📜 Sharable eslint configuration rimac technology uses in all of its projects.

Eslint Config Usage Install the library as a dev dependency alongside required dependencies using yarn add -D @rimac-technology/eslint-config

Nov 23, 2022

AdsPower supports Local API, which has functions like reading and writing account configuration information, opening and closing browsers, searching for accounts.

AdsPower supports Local API, which has functions like reading and writing account configuration information, opening and closing browsers, searching for accounts. Besides, it can cooperate with Selenium and Puppeteer to execute browser operations automatically.

Dec 1, 2022

Create Angular Dynamic Forms with only JSON configuration. Full grid layout supported.

Create Angular Dynamic Forms with only JSON configuration. Full grid layout supported.

Angular Dynamic Forms Angular component that allows the creation of dynamic forms. You can use this component in situations where you get the configur

Nov 17, 2022
Releases(v1.1.1)
Owner
Umbrellio
Umbrellio
Umbrellio
Engine editor for the engine-sim

Enginette An engine maker/editor for the engine-sim by AngeTheGreat. Warning: Code is still in development, thus it will change frequently Another War

null 39 Dec 15, 2022
Node.js Application Configuration

Configure your Node.js Applications release notes Introduction Node-config organizes hierarchical configurations for your app deployments. It lets you

Loren West 5.9k Jan 4, 2023
a Node.js boilerplate to start creating your telegram bot without too much configuration at the beginning

node-telegram-bot-starter-pack How to use clone the repo run npm install run cp .env.example .env and replace the variables with your data define your

Mohammad MohammadAlian 7 Sep 7, 2022
✨ Create server-rendered universal JavaScript applications with no configuration

Universal JavaScript applications are tough to setup. Either you buy into a framework like Next.js or Nuxt, fork a boilerplate, or set things up yours

Jared Palmer 11k Jan 7, 2023
✨ Create server-rendered universal JavaScript applications with no configuration

Universal JavaScript applications are tough to setup. Either you buy into a framework like Next.js or Nuxt, fork a boilerplate, or set things up yours

Jared Palmer 11k Jan 8, 2023
A toolkit for React, Preact, Inferno & vanilla JS apps, React libraries and other npm modules for the web, with no configuration (until you need it)

nwb nwb is a toolkit for: Quick Development with React, Inferno, Preact or vanilla JavaScript Developing: React Apps Preact Apps Inferno Apps Vanilla

Jonny Buchanan 5.5k Jan 3, 2023
Sanitize untrusted HTML (to prevent XSS) with a configuration specified by a Whitelist

Sanitize untrusted HTML (to prevent XSS) with a configuration specified by a Whitelist. xss is a module used to filter input from users to prevent XSS

老雷 4.8k Jan 2, 2023
📦🚀 Blazing fast, zero configuration web application bundler

Features ?? Blazing fast bundle times - multicore compilation, and a filesystem cache for fast rebuilds even after a restart. ?? Out of the box suppor

Parcel 41.8k Jan 4, 2023
📦 Zero-configuration bundler for tiny modules.

Microbundle The zero-configuration bundler for tiny modules, powered by Rollup. Guide → Setup ✯ Formats ✯ Modern Mode ✯ Usage & Configuration ✯ All Op

Jason Miller 7.4k Dec 28, 2022
📦🚀 Blazing fast, zero configuration web application bundler

Features ?? Blazing fast bundle times - multicore compilation, and a filesystem cache for fast rebuilds even after a restart. ?? Out of the box suppor

Parcel 41.8k Jan 4, 2023