31 lines
820 B
TypeScript
31 lines
820 B
TypeScript
/**
|
|
* Environment for the backend API tests.
|
|
*
|
|
* Values come from tests/.env (loaded in tests/setup.ts).
|
|
*/
|
|
|
|
export const API_BASE_URL = (process.env.API_BASE_URL ?? 'http://localhost:8787').replace(
|
|
/\/+$/,
|
|
''
|
|
)
|
|
|
|
export const TRPC_URL = `${API_BASE_URL}/api/trpc`
|
|
|
|
function required(name: string): string {
|
|
const value = process.env[name]
|
|
if (!value || !value.trim()) {
|
|
throw new Error(
|
|
`[api-tests] ${name} is not set. Copy apps/backend/tests/.env.example to ` +
|
|
`apps/backend/tests/.env and fill it in.`
|
|
)
|
|
}
|
|
return value.trim()
|
|
}
|
|
|
|
export function adminCredentials() {
|
|
return { name: required('ADMIN_NAME'), password: required('ADMIN_PASSWORD') }
|
|
}
|
|
|
|
export function userCredentials() {
|
|
return { identifier: required('USER_IDENTIFIER'), password: required('USER_PASSWORD') }
|
|
}
|