29 lines
622 B
TypeScript
Raw Normal View History

2020-12-30 17:21:56 +01:00
import http from 'http';
2021-01-01 14:14:19 +01:00
export class Response extends http.IncomingMessage {
2020-12-30 17:21:56 +01:00
body?: string;
}
2021-01-01 14:14:19 +01:00
export function get (
2020-12-30 17:21:56 +01:00
headers: http.OutgoingHttpHeaders = {}
): Promise<Response> {
return new Promise ((resolve) => {
http.get ('http://localhost:3000', { headers }, (res: Response) => {
let body = '';
res.on ('data', (d) => {
body += d;
});
res.on ('end', () => {
res.body = body;
resolve (res);
});
});
});
}
2021-01-01 14:14:19 +01:00
export function modify_signature (signature: string): string {
const dec = signature.split ('.');
dec[1] = '';
return dec.join ('.');
}