Skip to content

codesupport/inherited-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Inherited Config

About

This repository contains the code for Inherited Config - a configuration library with inheritance support for multiple environments for TypeScript projects.

Usage

  1. Install the package using npm i @codesupport/inherited-config
  2. In the entry point of your project add the following code:
import InheritedConfig from "@codesupport/inherited-config";

const config = new InheritedConfig();
  1. Use config.getValue() to get a value from the config, for example:
if (config.getValue<boolean>("ENABLE_LOGS")) {
    console.log("Logs are enabled.");
}

If your config.json and corresponding environment based config files are not in the root of your project you can change the path InheritedConfig looks at by using the path option. For example, if your config.json is within the src directory you can do:

import InheritedConfig from "@codesupport/inherited-config";

const config = new InheritedConfig({
    path: "src"
});

If you're having problems with InheritedConfig reading your config files you can enable debug logging:

import InheritedConfig from "@codesupport/inherited-config";

const config = new InheritedConfig({
    log: true
});

Scripts

  • To build the source code use npm run build
  • To test the code use npm test
  • To lint the code use npm run lint

Any Questions? Feel free to mention @LamboCreeper#6510 in the CodeSupport Discord.