jeremydaly / lambda-api

Lightweight web framework for your serverless applications
https://serverless-api.com
MIT License
1.41k stars 125 forks source link

Compatible versions of lambda-api 1.x and aws-sdk 3.x #234

Closed felipeoriani closed 1 year ago

felipeoriani commented 1 year ago

Hello guys,

I have a node/typescript project running in a lambda and I need to send a file to the client. I am using the lambda-api 1.0.1 and some packages from AWS-SDK 3.x, for example @aws-sdk/lib-storage, @aws-sdk/client-s3 and @aws-sdk/client-api-gateway all in version 3.x.

My code looks like this:

api.get('/export', async (req, res) => { 
   const s3path = getFilePath(); // return "s3://my-bucket/file.pdf"
   res.SendFile(s3path);
});

And when I try to run this request, I got a 500 error.

I got it working after I downgrade to the lambda-api 0.12.0 and install aws-sdk 2.1354.0 (current version). Given the AWS modularized the packages for sdk for each service, what packages should I add in my project to make it work with lambda-api 1.0.1 and read the file from S3 bucket to use response.sendFile?

Thank you

naorpeled commented 1 year ago

Hey @felipeoriani

thanks for opening this issue!

I think I've found the root cause for the 500 error. Will look further into it tomorrow and keep you updated with the progress 🙏

felipeoriani commented 1 year ago

Hello @naorpeled

I just downgrande the version of the lambda-api to 0.12.0 and aws-sdk to 2.x and it worked. It would be great to have a fix for it on lambda-api 1.x.

Thank you!

naorpeled commented 1 year ago

Hello @naorpeled

I just downgrande the version of the lambda-api to 0.12.0 and aws-sdk to 2.x and it worked. It would be great to have a fix for it on lambda-api 1.x.

Thank you!

Hey, I'm sorry, I didn't get to it yet :(

I want to push a fix after throughly testing it

naorpeled commented 1 year ago

Hey @felipeoriani I found the root cause and did some testing that seems to work, tomorrow will fix the tests and re-review my solution (#236) and hopefully release the new version.

Sorry for the huge delay 🙏