@koadz/configs - v1.2.2

Koadz Platform Config

Config is a TypeScript class designed to manage application configuration using the cosmiconfig library. It allows for both synchronous and asynchronous retrieval of configuration settings.

Before you can use Config, ensure you have installed @koadz/config:

npm install @koadz/config

Usage Importing the Class

First, import the Config class into your project:

import Config from "@koadz/config";

Creating an Instance of Config, you can optionally pass configuration options during instantiation:

const config = new Config({
configFileName: "customName",
searchPlaces: ["customName.config.js", "customName.config.json"],
});

Setting Configuration Options, to update configuration options after instantiation:

config.setConfig({ configFileName: "newConfigName" });

Retrieving Configuration Synchronously:

const configResult = config.getConfigSync();
console.log(configResult);

Local and Global Configuration

Retrieving Configuration Asynchronously:

async function fetchConfig() {
const configResult = await config.getConfig();
console.log(configResult);
}
fetchConfig();

This README.md provides a basic guide to help users understand and utilize the Config class effectively. Adjust the paths and examples according to your actual project structure and requirements.