Skip to content

Add support for APIGateway event with custom authorizer #26

@krishnagopinath

Description

@krishnagopinath

Some AWS lambdas are invoked via custom authorizers and they have the type APIGatewayProxyWithLambdaAuthorizerEvent<TAuthorizerContext>. With the current 'aws:apiGateway' eventType, setting up something like this:

const event = createEvent('aws:apiGateway', {
  body: JSON.stringify({ message: 'this is a message' }),
  requestContext: {
	authorizer: {
	  user: JSON.stringify({ id: 12345, name: 'Satoshi Nakamoto', roleId: 1 }),
	},
  },
});

... results in this TypeScript error:

Type '{ authorizer: { user: string; }; }' is missing the following properties from type 'APIGatewayEventRequestContextWithAuthorizer<APIGatewayEventDefaultAuthorizerContext>': accountId, apiId, protocol, httpMethod, and 7 more.

I wonder if it would make sense to either

  1. Apply a DeepPartial on body to allow for nested requestContext.
  2. Create a new eventType called 'aws:apiGatewayWithCustomAuthorizer'.

I like Option 2 better because of it being hyper clear about what it is doing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions