Download server/env.ts from Jiangxz/GSearch: direct link, hf CLI and curl.
- Browser
- Download file 715 Bytes
-
https://huggingface.co/spaces/Jiangxz/GSearch/resolve/main/server/env.ts
- Command line
-
hf download hf://spaces/Jiangxz/GSearch/server/env.ts
-
curl -L -o env.ts https://huggingface.co/spaces/Jiangxz/GSearch/resolve/main/server/env.ts
715 Bytes
| import dotenv from "dotenv"; | |
| import path from "path"; | |
| import { fileURLToPath } from "url"; | |
| const __filename = fileURLToPath(import.meta.url); | |
| const __dirname = path.dirname(__filename); | |
| const envPath = path.resolve(__dirname, "../.env"); | |
| export function setupEnvironment() { | |
| const result = dotenv.config({ path: envPath }); | |
| if (result.error) { | |
| throw new Error( | |
| `Failed to load .env file from ${envPath}: ${result.error.message}` | |
| ); | |
| } | |
| if (!process.env.GOOGLE_API_KEY) { | |
| throw new Error( | |
| "GOOGLE_API_KEY environment variable must be set in .env file" | |
| ); | |
| } | |
| return { | |
| GOOGLE_API_KEY: process.env.GOOGLE_API_KEY, | |
| NODE_ENV: process.env.NODE_ENV || "development", | |
| }; | |
| } | |