Skip to content

Commit

Permalink
Use Context rather than APIGatewayEventRequestContext (#13)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
hayd and lucacasonato authored Feb 8, 2020
1 parent 255f461 commit c407cc2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ If you're unfamiliar with now runtimes, please read the [runtime docs](https://z

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

export async function handler(event: APIGatewayEvent, context: APIGatewayEventRequestContext) {
export async function handler(
event: APIGatewayProxyEvent,
context: Context
): Promise<APIGatewayProxyResult> {
return {
statusCode: 200,
body: `Welcome to deno ${Deno.version.deno} 🦕`,
Expand Down
11 changes: 6 additions & 5 deletions example/api/version.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import {
APIGatewayEventRequestContext,
APIGatewayEvent,
APIGatewayProxyEvent,
APIGatewayProxyResult,
Context,
} from 'https://deno.land/x/lambda/mod.ts';

export async function handler(
event: APIGatewayEvent,
context: APIGatewayEventRequestContext
) {
event: APIGatewayProxyEvent,
context: Context
): Promise<APIGatewayProxyResult> {
return {
statusCode: 200,
body: `Welcome to deno ${Deno.version.deno} 🦕`,
Expand Down

0 comments on commit c407cc2

Please sign in to comment.