UNPKG

@tsed/config

Version:
14 lines (13 loc) 613 B
import { inject } from "@tsed/di"; import { CONFIG_SOURCES } from "../constants/constants.js"; /** * Injects a configuration source by name and returns it as the specified type. * * @param {string} name - The name of the configuration source to retrieve. * @param {Partial<Pick<InvokeOptions, "useOpts" | "rebuild" | "locals">>} [opts] - Optional invocation options to customize the behavior of the injection. * @return {T} The configuration source cast to the specified type. */ export function injectConfigSource(name, opts) { const configs = inject(CONFIG_SOURCES, opts); return configs[name]; }