-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathconfig.utils.ts
More file actions
77 lines (71 loc) · 2.11 KB
/
config.utils.ts
File metadata and controls
77 lines (71 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import dotenv from "dotenv";
import path from "path";
import { fileURLToPath } from "url";
// This needs to be placed somewhere before attempting to access any environment variables
dotenv.config();
export interface UserCredentials {
username: string;
password: string;
sessionFile: string;
cookieName?: string;
}
interface Urls {
exuiDefaultUrl: string;
manageCaseBaseUrl: string;
citizenUrl: string;
idamWebUrl: string;
idamTestingSupportUrl: string;
serviceAuthUrl: string;
}
export interface Config {
users: {
caseManager: UserCredentials;
judge: UserCredentials;
};
urls: Urls;
}
export const config: Config = {
users: {
caseManager: {
username: getEnvVar("CASEMANAGER_USERNAME"),
password: getEnvVar("CASEMANAGER_PASSWORD"),
sessionFile:
path.join(fileURLToPath(import.meta.url), "../../.sessions/") +
`${getEnvVar("CASEMANAGER_USERNAME")}.json`,
cookieName: "xui-webapp",
},
judge: {
username: getEnvVar("JUDGE_USERNAME"),
password: getEnvVar("JUDGE_PASSWORD"),
sessionFile:
path.join(fileURLToPath(import.meta.url), "../../.sessions/") +
`${getEnvVar("JUDGE_USERNAME")}.json`,
cookieName: "xui-webapp",
},
},
urls: {
exuiDefaultUrl: "https://manage-case.aat.platform.hmcts.net",
manageCaseBaseUrl:
process.env.MANAGE_CASES_BASE_URL ||
"https://manage-case.aat.platform.hmcts.net/cases",
citizenUrl:
process.env.CITIZEN_FRONTEND_BASE_URL ||
"https://privatelaw.aat.platform.hmcts.net/",
idamWebUrl:
process.env.IDAM_WEB_URL ||
"https://idam-web-public.aat.platform.hmcts.net",
idamTestingSupportUrl:
process.env.IDAM_TESTING_SUPPORT_URL ||
"https://idam-testing-support-api.aat.platform.hmcts.net",
serviceAuthUrl:
process.env.S2S_URL ||
"http://rpe-service-auth-provider-aat.service.core-compute-aat.internal/testing-support/lease",
},
};
function getEnvVar(name: string): string {
const value = process.env[name];
if (!value) {
throw new Error(`Error: ${name} environment variable is not set`);
}
return value;
}