-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathawslambda.ts
More file actions
30 lines (25 loc) · 778 Bytes
/
Copy pathawslambda.ts
File metadata and controls
30 lines (25 loc) · 778 Bytes
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
import type { Writable } from 'stream';
import type { Handler, Context } from 'aws-lambda';
const anyGlobal: any = global;
export namespace awslambda {
export type HttpMetadata = {
statusCode: number;
headers: Record<string, string>;
cookies?: string[];
};
export namespace HttpResponseStream {
export function from(writable: Writable, metadata: HttpMetadata): Writable {
return anyGlobal.awslambda.HttpResponseStream.from(writable, metadata);
}
}
export type StreamHandler<Event> = (
event: Event,
responseStream: Writable,
context: Context,
) => void;
export function streamifyResponse<Event>(
handler: StreamHandler<Event>,
): Handler<any, any> {
return anyGlobal.awslambda.streamifyResponse(handler);
}
}