Skip to content
/ config Public

Chained application configuration files load

Notifications You must be signed in to change notification settings

c7s/config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NodeJS application configuration files loader

  • NodeJS, Typescript
  • Config chaining (hierarchy)
  • Multiple environments support, local overwrites
  • JSON/JS configs, JS is to use environment variables
  • Validation using class-validator library
  • Configs are typed

Usage

Load config:

    const configSource = new ConfigFileChain(
      path.resolve(__dirname, '../config'),
      process.env.PROJECT_ENV as string,
    );
    const configFactory = new ConfigFactory(configSource);

    const serverConfig = await configFactory.create<ServerConfig>(ServerConfig);

Create your own config type:

export class ExampleConfig extends Config {
  @IsNotEmpty()
  public value!: string;

  public getName(): string {
    return 'example';
  }
}

About

Chained application configuration files load

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published