SPB Git forge

spb/cancerindex

Public
37commits 1branches 0releases
2.9 MBsize
maindefault branch
10 days agolast push
TypeScript 97.2% SQL 1.5% CSS 0.6% JavaScript 0.5%
854 B · 25 lines typescript
Raw Blame History
1import { existsSync } from 'node:fs';2import path from 'node:path';3import { fileURLToPath } from 'node:url';45/**6 * Load the repository `.env` (two levels above apps/api) when present, then the cwd `.env`.7 * Values already set in the environment win (process.loadEnvFile never overrides).8 */9export function loadEnv(): void {10  const here = path.dirname(fileURLToPath(import.meta.url));11  const candidates = [path.resolve(here, '../../../../.env'), path.resolve(process.cwd(), '.env')];12  for (const candidate of candidates) {13    if (!existsSync(candidate)) continue;14    try {15      process.loadEnvFile(candidate);16    } catch {17      /* ignore malformed files */18    }19  }20  process.env.CI_SERVICE ??= 'api';21}2223export const API_HOST = () => process.env.API_HOST ?? '127.0.0.1';24export const API_PORT = () => Number(process.env.API_PORT ?? 8251);25