Download src/utils/getNessesaryEnvs.ts from lynfera/api: direct link, hf CLI and curl.
- Browser
- Download file 843 Bytes
-
https://huggingface.co/spaces/lynfera/api/resolve/main/src/utils/getNessesaryEnvs.ts
- Command line
-
hf download hf://spaces/lynfera/api/src/utils/getNessesaryEnvs.ts
-
curl -L -o getNessesaryEnvs.ts https://huggingface.co/spaces/lynfera/api/resolve/main/src/utils/getNessesaryEnvs.ts
843 Bytes
| type envsArrayType = { name: string; value: string }[]; | |
| const REQUIRED_ENVS = [ | |
| "API_ENDPOINT", | |
| "CONTAINER_API_TOKEN", | |
| "CLOUD_ACCESSKEY", | |
| "CLOUD_SECRETKEY", | |
| "CLOUD_BUCKET", | |
| "CLOUD_ENDPOINT", | |
| "KAFKA_USERNAME", | |
| "KAFKA_PASSWORD", | |
| "STORAGE_SERVER_ENDPOINT", | |
| ] as const; | |
| const getNessesaryEnvs = (): envsArrayType => { | |
| const envsArray: envsArrayType = []; | |
| const missing: string[] = []; | |
| for (const envName of REQUIRED_ENVS) { | |
| const value = process.env[envName]; | |
| if (!value) { | |
| missing.push(envName); | |
| } | |
| envsArray.push({ name: envName, value: value || "" }); | |
| } | |
| if (missing.length > 0) { | |
| console.log(`Missing required environment variables : ${missing.join(", ")}`); | |
| throw new Error(`Server Error Missing required environment variables : ${missing.join(", ")}`); | |
| } | |
| return envsArray; | |
| }; | |
| export default getNessesaryEnvs; | |