Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for APIGateway event with custom authorizer #26

Open
krishnagopinath opened this issue Apr 22, 2021 · 0 comments · May be fixed by Metronome-Industries/node-mock-aws-events#5

Comments

@krishnagopinath
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant