Skip to content

Commit c407cc2

Browse files
haydlucacasonato
andauthored
Use Context rather than APIGatewayEventRequestContext (#13)
* Use Context rather than APIGatewayEventRequestContext Note: APIGatewayEvent is deprecated and APIGatewayProxyEvent should be preferred. I also added the APIGatewayProxyResult type to the handler as I think this is useful to have in the example - it will fail to compile if the returned value is missing attributes. APIGatewayEventRequestContext is available on event.requestContext, it's not the second argument for the handler. * Trigger CI * Also trigger CI on PR * Revert last commit Co-authored-by: Luca Casonato <[email protected]>
1 parent 255f461 commit c407cc2

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@ If you're unfamiliar with now runtimes, please read the [runtime docs](https://z
2121

2222
```ts
2323
// api/hello.ts
24-
import { APIGatewayEventRequestContext, APIGatewayEvent } from 'https://deno.land/x/lambda/mod.ts';
24+
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'https://deno.land/x/lambda/mod.ts';
2525

26-
export async function handler(event: APIGatewayEvent, context: APIGatewayEventRequestContext) {
26+
export async function handler(
27+
event: APIGatewayProxyEvent,
28+
context: Context
29+
): Promise<APIGatewayProxyResult> {
2730
return {
2831
statusCode: 200,
2932
body: `Welcome to deno ${Deno.version.deno} 🦕`,

example/api/version.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import {
2-
APIGatewayEventRequestContext,
3-
APIGatewayEvent,
2+
APIGatewayProxyEvent,
3+
APIGatewayProxyResult,
4+
Context,
45
} from 'https://deno.land/x/lambda/mod.ts';
56

67
export async function handler(
7-
event: APIGatewayEvent,
8-
context: APIGatewayEventRequestContext
9-
) {
8+
event: APIGatewayProxyEvent,
9+
context: Context
10+
): Promise<APIGatewayProxyResult> {
1011
return {
1112
statusCode: 200,
1213
body: `Welcome to deno ${Deno.version.deno} 🦕`,

0 commit comments

Comments
 (0)