kibertoad / frontend-config-scope

ConfigScope implementation, adjusted for the frontend

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

frontend-config-scope

NPM Version Build Status Coverage Status

Config management for the frontend

Basic example

import { ConfigScope } from 'frontend-config-scope'

const envVars = {
  ...import.meta.env,
}

const config = new ConfigScope(envVars)

export const SOME_API_URL = config.getMandatory('API_URL') // this will throw an error if not set
export const BUGSNAG_API_KEY = config.getOptional('VITE_BUGSNAG_API_KEY', '') // this will use default value if not set
export const ENV = config.getMandatoryOneOf('VITE_ENV', ['local', 'development', 'production']) // this will throw an error if not one of the supported values

About

ConfigScope implementation, adjusted for the frontend

License:MIT License


Languages

Language:TypeScript 100.0%