Open DaveLo opened 2 months ago
4.5.3
aws lambda
Create a HTTP Api proxy v2 endpoint in aws-lambda and use a lambda authorizer in front of it, but practically since this is a typings issue you can set up your bindings like:
type Bindings = { Bindings: { event: LambdaEvent, lambdaContext:LambdaContext }; Variables: { userId: string }; }; const app = new Hono<Bindings>();
Then try and set a value from the lambda authorizer context
app.use(async (ctx, next) => { ctx.set( "userId", ctx.env.event.requestConstext.authorizer.lambda.userId ); });
This throws up TS warnings because the current setup of LambdaEvent only has a key for iam auth.
LambdaEvent
I would expect the types to work correctly.
A typescript error.
My current workaround is to do this:
type Event = LambdaEvent & { requestContext: { authorizer: { lambda: { userId: string }; } } }; type Bindings = { Bindings: { event: Event, lambdaContext:LambdaContext }; Variables: { userId: string }; };
I referenced @types/aws-lambda to figure out typings here.
Hi @DaveLo Thank you for raising the issue.
@watany-dev Can you take a look at it?
What version of Hono are you using?
4.5.3
What runtime/platform is your app running on?
aws lambda
What steps can reproduce the bug?
Create a HTTP Api proxy v2 endpoint in aws-lambda and use a lambda authorizer in front of it, but practically since this is a typings issue you can set up your bindings like:
Then try and set a value from the lambda authorizer context
This throws up TS warnings because the current setup of
LambdaEvent
only has a key for iam auth.What is the expected behavior?
I would expect the types to work correctly.
What do you see instead?
A typescript error.
My current workaround is to do this:
Additional information
I referenced @types/aws-lambda to figure out typings here.