-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
FastifyAdapter can't take a FastifyInstance due to a type error #12979
Comments
Do you think a better approach would be to use the |
I was able to fix the code myself using the
I know it's a separate issue but it would be pretty cool to get the serverless documentation updated with a proper example of how to run a Fastify-based Nest.js application in a Lambda. I'm trying this specific solution to reach a balance of speed (which lowers cost in Lambdas) & avoiding running an instance anywhere (as a container or an EC2) to demonstrate and MVP for a project with Nest.js. It's pretty cool to think that you could start a project this way and when traffic increases, with a few small tweaks, you could probably migrate to EKS or Kubernetes. |
Actually I don't think that fixes it entirely because when I try to run the code as a containerized Lambda created by SST, I get the following error:
There's a demo repo here. Perhaps using |
Your local |
@kamilmysliwiec thanks for the response! I'm going through the fundamentals course now so it feels like I'm replying to a celebrity! Anyway, I took your advice and locked the version to 4.25.1; however, I'm still getting the decorate response error: The error is as follows:
I think my next step is actually going to be to abandon the serverless Fastify adapter and see if I can get it working without. I was able to recently deploy to AWS via an ECS+EC2+ASG+ALB setup but for demo-ing and early growth, Lambda would be extremely awesome. |
Actually, @kamilmysliwiec , when I restored the code to a prior version that declared the instance separately instead of trying to reference it (here), I was able to get it working. Thanks for the help! |
Is there an existing issue for this?
Current behavior
I am following some example code (that needed adapting) to deploy a Nest.js application using Fastify on AWS Lambda. The code is found in this issue and this PR.
When I adapt the code to be error free, I get a type error at the point where I create the
FastifyAdapter
using aFastifyInstance
:Minimum reproduction code
https://github.com/toptal-dave/fastify-adapter-type-error
Steps to reproduce
All I did was replace the original code with the following code in the
main.ts
:Expected behavior
It should be possible to pass a
FastifyInstance
intoFastifyAdapter
without causing a type error because it looks likeFastifyAdapter
takes either options or an instance by the typing:Package
@nestjs/common
@nestjs/core
@nestjs/microservices
@nestjs/platform-express
@nestjs/platform-fastify
@nestjs/platform-socket.io
@nestjs/platform-ws
@nestjs/testing
@nestjs/websockets
Other package
@fastify/aws-lambda
NestJS version
10.3.0
Packages versions
Also, the output of
npx nest info
:Node.js version
18.19.0
In which operating systems have you tested?
Other
No response
The text was updated successfully, but these errors were encountered: