the configuration definition object to get the Type for
import { from } from 'env-var';
export const getConfigDefinitions = (
variables: NodeJS.ProcessEnv = process.env,
) => {
const env = from(variables);
return {
environment: () => env.get('NODE_ENV').required().asEnum(['development', 'production', 'test']),
serviceId: () => env.get('SERVICE_ID').required().asString(),
port: () => env.get('PORT').default(10100).asPortNumber(),
// many more...
}
}
// validation will not happen at that point in time
const config = getConfigType(getConfigDefinitions());
export type Config = typeof config;
Generated using TypeDoc
Get a TypeScript type for the (picked) configuration object