import path from "node:path"
import dotenv from "dotenv"

dotenv.config({ path: path.resolve(__dirname, "../.env.e2e") })

function required(name: string): string {
  const value = process.env[name]
  if (!value) throw new Error(`Missing required env var ${name} - copy .env.e2e.example to .env.e2e and fill it in.`)
  return value
}

export const env = {
  baseUrl: process.env.E2E_BASE_URL ?? "http://localhost:3000",
  apiUrl: process.env.E2E_API_URL ?? "http://localhost:5224",
  get adminEmail() {
    return required("E2E_ADMIN_EMAIL")
  },
  get adminPassword() {
    return required("E2E_ADMIN_PASSWORD")
  },
}

export const AUTH_STORAGE_STATE = path.resolve(__dirname, "../.auth/admin.json")
