🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@codex-team/config-loader

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codex-team/config-loader

Config loader for Cloud Native applications

1.0.0
latest
Source
npm
Version published
Maintainers
1
Created
Source

config-loader

Config loader for Cloud Native applications

Features

  • Configuration via YAML files
  • Combining and inheriting a configuration from multiple files
  • Override configuration values with environment variables
  • Provide default values for configuration

What's not included

  • Reading command line arguments with config files locations
  • Configuration validation

Installation

npm install @codex-team/config-loader

yarn add @codex-team/config-loader

Usage

In this example we will load configuration from app-config.yaml and app-config.local.yaml files. Zod is used for configuration validation, but you can use any other library.

import {loadConfig} from '@codex-team/config-loader';
import {z} from 'zod';

const AppConfig = z.object({
    host: z.string(),
    port: z.number(),
});

export type AppConfig = z.infer<typeof AppConfig>;

const defaultConfig: AppConfig = {
    host: '0.0.0.0',
    port: 3000,
};

const paths = [
    `./app-config.yaml`,
    `./app-config.local.yaml`,
];

const loadedConfig = loadConfig(...[defaultConfig, ...paths]);

const appConfig = AppConfig.parse(loadedConfig);

export default appConfig;

FAQs

Package last updated on 30 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts