Skip to content

Add support for APIGateway event with custom authorizer #26

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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