rdlabo-team / serverless-nestjs

nestjs use serverlessframework and lambda
345 stars 71 forks source link

Reintroduce async/await to handler #13

Closed Thomas-X closed 4 years ago

Thomas-X commented 4 years ago

Saw the async handler was removed due to an issue with aws-serverless-express. It's an issue related to the fact that async handlers return a promise, which the serverless package tries to proxy, resulting in malformed response back to API Gateway

I.e doing something like the following in your handler should fix the issue you were facing:

return awsServerlessExpress.proxy(server, event, context, 'PROMISE').promise;

Related commit https://github.com/rdlabo/serverless-nestjs/commit/84db18ea4c529450b557f88a02aff1df043206cc

rdlabo commented 4 years ago

Thanks for Issue. I fixed it. Please check!