Landed on this article as I was searching on same topic. While this approach works for migrating existing express apps / nestjs to serverless model. I'm curious about the anti-pattern as well i.e I was thinking one smaller function for each route would have faster response/startup time? With this approach of deploying as one function when the application grows, it may slow down on startup/response times.
Having one or more functions really depends of what you're trying to achieve. Having your whole api as one functions has drawbacks yes, like increased cold start time and and slightly slower response time due to the framework additional routing. It can be acceptable or not, depending of your use case. If you're looking for the best performance and fastest response times then you will better with separate functions and relying on the provider's routing. For that there's a Nestjs WIP compiler that provides additional annotations to deploy your app as separate functions, but there's no public doc for it yet: github.com/nestjs/serverless-core
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Landed on this article as I was searching on same topic. While this approach works for migrating existing express apps / nestjs to serverless model. I'm curious about the anti-pattern as well i.e I was thinking one smaller function for each route would have faster response/startup time? With this approach of deploying as one function when the application grows, it may slow down on startup/response times.
Having one or more functions really depends of what you're trying to achieve. Having your whole api as one functions has drawbacks yes, like increased cold start time and and slightly slower response time due to the framework additional routing. It can be acceptable or not, depending of your use case. If you're looking for the best performance and fastest response times then you will better with separate functions and relying on the provider's routing. For that there's a Nestjs WIP compiler that provides additional annotations to deploy your app as separate functions, but there's no public doc for it yet: github.com/nestjs/serverless-core