-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.ts
More file actions
42 lines (38 loc) · 1.28 KB
/
main.ts
File metadata and controls
42 lines (38 loc) · 1.28 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
import DatadogGateway from './src/gateway/datadog-gateway';
import JsonGateway from './src/gateway/json-gateway';
import LighthouseGateway from './src/gateway/lighthouse-gateway';
import { monitoringUsecase } from './src/usecase/monitoring-usecase';
(async () => {
if (!process.env.DD_APP_KEY) {
throw new Error('envvar DD_APP_KEY is not defined');
}
if (!process.env.DD_API_KEY) {
throw new Error('envvar DD_API_KEY is not defined');
}
let environment: 'production' | 'development' | 'staging' = 'development';
if (
process.env.ENVIRONMENT === 'production' ||
process.env.ENVIRONMENT === 'development' ||
process.env.ENVIRONMENT === 'staging'
) {
environment = process.env.ENVIRONMENT;
} else if (!!process.env.ENVIRONMENT) {
throw new Error(
`envvar ENVIRONMENT should be "production", "staging" or "development". ENVIRONMENT: "${process.env.ENVIRONMENT}"`
);
}
const jsonGateway = new JsonGateway();
const lighthouseGateway = new LighthouseGateway();
const datadogGateway = new DatadogGateway(
process.env.DD_API_KEY,
process.env.DD_APP_KEY,
environment
);
try {
await monitoringUsecase(jsonGateway, lighthouseGateway, datadogGateway);
} catch (e) {
console.error(e);
process.exit(1);
}
process.exit(0);
})();