Skip to content

Latest commit

 

History

History
99 lines (67 loc) · 2.22 KB

README.md

File metadata and controls

99 lines (67 loc) · 2.22 KB

nfigure

nfigure is a configuration management tool brought to you by Kintaman team at AokiApp.

Features

  • Simple and intuitive syntax
  • Supports patching and merging configurations
  • Can be loaded from files, environment variables, or other sources
  • Zero dependencies
  • Plugins feature for extending functionality
  • Supports multiple configuration formats (JSON, YAML, TOML, etc.)*
  • Easy-to-setup helper scripts(WIP)
  • Deno support(Partially)
  • Type-safe configuration values*
  • Validation*
  • Version/Environment assertion*
  • Encryption*
  • And more...

*: With optional plugins

Installation

Express installation with helper script

To install nfigure, simply run the following command in the project directory you want to use it in:

npx @kintaman-co/nfigure init

Manual installation

To install nfigure manually, run the following command:

npm install @kintaman-co/nfigure

You can also install the plugins you need.

Here is the list of external plugins:

Configuration Loading Rules

Usage

Basic usage

Set up your configuration file as config.json:

{
  "message": "Hello, world!"
}

And then use it in your application:

import config from "@kintaman-co/nfigure";

console.log(config.message);

Advanced usage

If you want to customize the configuration, you can create a configuration file.

Here is an example of a configuration with @kintaman-co/nfigure-typebox plugin:

// config.js
import { nfigure } from "@kintaman-co/nfigure";
import { validator as typeboxValidator } from "@kintaman-co/nfigure-typebox";
import { Type } from "@sinclair/typebox";

const schema = Type.Object({
  PORT: Type.String(),
  DATABASE_URL: Type.String(),
});

export default nfigure({
  validator: typeboxValidator(schema), // give types and validates the configuration
});

And then use it in your application:

import config from "./config";

console.log(config.PORT); // PORT will be typed and validated

For more configuration options, see the configuration documentation.