-
-
Notifications
You must be signed in to change notification settings - Fork 814
Expand file tree
/
Copy pathaws-lambda.ts
More file actions
32 lines (26 loc) · 780 Bytes
/
aws-lambda.ts
File metadata and controls
32 lines (26 loc) · 780 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
31
32
import "#nitro/virtual/polyfills";
import { useNitroApp } from "nitro/app";
import { awsRequest, awsResponseHeaders, awsResponseBody } from "./_utils.ts";
import type {
APIGatewayProxyEvent,
APIGatewayProxyEventV2,
APIGatewayProxyResult,
APIGatewayProxyResultV2,
Context,
} from "aws-lambda";
const nitroApp = useNitroApp();
export async function handler(
event: APIGatewayProxyEvent | APIGatewayProxyEventV2,
context: Context
): Promise<APIGatewayProxyResult | APIGatewayProxyResultV2> {
const request = awsRequest(event, context);
const response = await nitroApp.fetch(request);
return {
statusCode: response.status,
...awsResponseHeaders(response),
...(await awsResponseBody(response)),
};
}
export default {
fetch: nitroApp.fetch,
};