-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvariables.js
32 lines (30 loc) · 1 KB
/
variables.js
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
import dotenv from 'dotenv';
dotenv.config();
const tenant_id = process.env.TENANT_ID;
export const domains = {
us: 'api.courier.com',
eu: 'api.eu.courier.com',
};
export const authorizations = {
us: process.env.US_AUTHORIZATION,
eu: process.env.EU_AUTHORIZATION,
};
export const graphqlEndpoint = (environment) => ({
us: `https://${domains.us}/studio/q?tenantId=${tenant_id}${
environment === 'test' ? '&env=test' : ''
}`,
eu: `https://${domains.eu}/studio/q?tenantId=${tenant_id}${
environment === 'test' ? '&env=test' : ''
}`,
});
export const getRestEndpoint = (environment, path, query = {}) => {
const params = new URLSearchParams({ ...query, tenantId: tenant_id });
return {
us: `https://api.courier.com/studio${
environment === 'test' ? '/test' : ''
}${path}?${params.toString()}`,
eu: `https://api.eu.courier.com/studio${
environment === 'test' ? '/test' : ''
}${path}?${params.toString()}`,
};
};