UNPKG

application-services

Version:

Out of the box application environment and configuration service.

32 lines (31 loc) 1.21 kB
import { type ImporterService, type LogService } from 'common-services'; import { type BaseAppEnv, type ProcessEnvConfig } from './ENV.js'; export type BaseAppConfig = ProcessEnvConfig; export interface AppConfig extends BaseAppConfig { } export type AppConfigDependencies<T extends BaseAppEnv> = { APP_ENV: T; MAIN_FILE_URL: string; importer: ImporterService<{ default: AppConfig; }>; log?: LogService; }; declare const _default: typeof initAppConfig; export default _default; /** * Initialize the APP_CONFIG service according to the APP_ENV * @param {Object} services * The services `APP_CONFIG` depends on * @param {Object} services.APP_ENV * The injected `APP_ENV` value * @param {String} services.MAIN_FILE_URL * An URL pointing to the main file run * @param {Object} services.importer * A service allowing to dynamically import ES modules * @param {Object} [services.log=noop] * An optional logging service * @return {Promise<Object>} * A promise of a an object the actual configuration properties. */ declare function initAppConfig<T extends BaseAppEnv>({ APP_ENV, MAIN_FILE_URL, importer, log, }: AppConfigDependencies<T>): Promise<AppConfig>;