MCPcopy Create free account
hub / github.com/boringstack-xyz/boringstack / validateEnv

Function validateEnv

apps/api/src/config/env/validate.ts:818–838  ·  view source on GitHub ↗
(source: EnvSource = process.env)

Source from the content-addressed store, hash-verified

816};
817
818export const validateEnv = (source: EnvSource = process.env): Env => {
819 const raw = readRaw(source);
820 const schemaErrors = formatSchemaErrors(raw);
821
822 if (schemaErrors.length > 0) {
823 throw new Error(
824 `Invalid environment configuration:\n - ${schemaErrors.join("\n - ")}`
825 );
826 }
827
828 const parsed = Value.Cast(envSchema, raw);
829 const invariantErrors = checkInvariants(parsed);
830
831 if (invariantErrors.length > 0) {
832 throw new Error(
833 `Invalid environment configuration:\n - ${invariantErrors.join("\n - ")}`
834 );
835 }
836
837 return parsed;
838};

Callers 3

index.tsFile · 0.90
baseEnvFunction · 0.90
validate.test.tsFile · 0.90

Calls 3

readRawFunction · 0.85
formatSchemaErrorsFunction · 0.85
checkInvariantsFunction · 0.85

Tested by 1

baseEnvFunction · 0.72