dougmoscrop / serverless-http

Use your existing middleware framework (e.g. Express, Koa) in AWS Lambda 🎉
Other
1.71k stars 164 forks source link

Using this library with AWS function URLs? #273

Open ffMathy opened 1 year ago

ffMathy commented 1 year ago

AWS Lambda Function URLs are different from regular API Gateway URLs, in that they support IAM authentication, and they are also cheaper to use.

Does this library have support for an AWS Lambda that has a function URL instead of an API Gateway integration?

dougmoscrop commented 1 year ago

It will need some modification, I can't promise I will work on it but I might, otherwise PRs welcome

jdrydn commented 11 months ago

It works fine on it's own (without IAM authentication), if you need to access the original event I suggest you use the options argument to amend the incoming req:

export const handler = serverless(app,{
  request(req, event, context) {
    // Append event & context to the request
    req.lambdaEvent = event;
    req.lambdaContext = context;
  },
});

Then in your framework, req.lambdaEvent would have the original event for you to access the IAM-specific request context you're after.

ptz0n commented 8 months ago

I can confirm that Lambda Function URL's works fine.