application-services
Version:
Out of the box application environment and configuration service.
33 lines (32 loc) • 1.28 kB
TypeScript
import { type ServiceProperties } from 'knifecycle';
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 interface AppConfigDependencies<T extends BaseAppEnv> {
APP_ENV: T;
MAIN_FILE_URL: string;
importer: ImporterService<{
default: AppConfig;
}>;
log?: LogService;
}
/**
* 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>;
declare const _default: ServiceProperties & typeof initAppConfig;
export default _default;