-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
index.ts
39 lines (35 loc) · 1.14 KB
/
index.ts
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
import type { AddressInfo } from 'net';
import type { BaseTransportOptions, Envelope, Transport, TransportMakeRequestResponse } from '@sentry/types';
import type { Express } from 'express';
/**
* Debug logging transport
*/
export function loggingTransport(_options: BaseTransportOptions): Transport {
return {
send(request: Envelope): Promise<TransportMakeRequestResponse> {
// eslint-disable-next-line no-console
console.log(JSON.stringify(request));
return Promise.resolve({ statusCode: 200 });
},
flush(): PromiseLike<boolean> {
return new Promise(resolve => setTimeout(() => resolve(true), 1000));
},
};
}
/**
* Starts an express server and sends the port to the runner
*/
export function startExpressServerAndSendPortToRunner(app: Express): void {
const server = app.listen(0, () => {
const address = server.address() as AddressInfo;
// eslint-disable-next-line no-console
console.log(`{"port":${address.port}}`);
});
}
/**
* Sends the port to the runner
*/
export function sendPortToRunner(port: number): void {
// eslint-disable-next-line no-console
console.log(`{"port":${port}}`);
}