UNPKG

@contextjs/configuration

Version:

Lightweight configuration system for ContextJS applications, featuring async providers and environment variable support.

20 lines (19 loc) 601 B
import { ObjectExtensions, StringExtensions } from "@contextjs/system"; export class Configuration { application; providers = []; useEnvironmentVariables = false; constructor(application) { this.application = application; } async getValueAsync(key) { if (StringExtensions.isNullOrWhitespace(key)) return null; for (const provider of this.providers) { const value = await provider.getValueAsync(key); if (!ObjectExtensions.isNullOrUndefined(value)) return value; } return null; } }