27 lines
931 B
TypeScript
27 lines
931 B
TypeScript
import { readFileSync } from 'node:fs';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
/** Same idea as e2e/support/env.ts - read the seeded demo credentials from `.env` rather than hard-coding them. */
|
|
function readDotEnv(): Record<string, string> {
|
|
const path = fileURLToPath(new URL('../../../.env', import.meta.url));
|
|
const text = readFileSync(path, 'utf-8');
|
|
const values: Record<string, string> = {};
|
|
for (const line of text.split('\n')) {
|
|
const match = /^([A-Z0-9_]+)=(.*)$/.exec(line.trim());
|
|
const key = match?.[1];
|
|
if (key !== undefined) values[key] = match?.[2] ?? '';
|
|
}
|
|
return values;
|
|
}
|
|
|
|
const env = readDotEnv();
|
|
|
|
export const DEMO_ANALYST = {
|
|
email: env.DEMO_ANALYST_EMAIL ?? 'analyst@example.com',
|
|
password: env.DEMO_ANALYST_PASSWORD ?? 'Analyst-Passw0rd!',
|
|
};
|
|
|
|
export const API_BASE_URL = process.env.E2E_BASE_URL
|
|
? `${process.env.E2E_BASE_URL}/api/v1`
|
|
: 'http://localhost:8080/api/v1';
|