Hi there, is anyone using NestJS <https://docs.nes...
# help
Hi there, is anyone using NestJS https://docs.nestjs.com/ for their backends with SST ? if so how are you making it work together ?
From what I read nestjs requires a different build process is there a way to build your functions and than have SST use those pre-build functions instead of SST building them?
For others that had this issue. I had to do this to make nestjs work: 1. Add this to these compiler options:
Copy code
"compilerOptions": {
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
2. Add a new file to the root
also install
Copy code
const { esbuildDecorators } = require("@anatine/esbuild-decorators");

module.exports = [esbuildDecorators()];
3. Add these function configs
Copy code
      externalModules:["@nestjs/websockets","@nestjs/microservices", "cache-manager"],
      esbuildConfig: {
        plugins: "esbuild.js",
If you use the modules that are marked as external here install them and remove them from the list.
@Kujtim Hoxha thanks for sharing! Btw, are all urs Nestjs controllers behind the same route? ie. only 1
ANY /{proxy+}
route in Api?
I think unfortunately that is the only way you can…
I am not using nestjs yet
I am playing around with it and checking it out
My plan is maybe using it for each of my services (domain servcies)
so I would have something like
Copy code
ANY /users/{proxy+}
ANY /something/{proxy+}
I do not yet know how that will affect my app tho
currently each function is an api endpoint
Ah gotcha.
@manitej let’s create an example with Kujtim’s setup when we get a chance. Opened an GH issue w/ the steps mentioned above https://github.com/serverless-stack/serverless-stack/issues/1360
Alright 👌 I'll make one soon. Also you mentioned next instead of nest in description @Frank
NestJs doesnt work well with the serverless model presented by aws.
NestJs is for microservices, we run it on K8s.
But Lambda is more like nano-services, using api gw and other infrastructure services.
With Nest you have all together.
You can still create a mono-lambda or single-lambda, but thats not what aws recommends for your application, you should have multiple lambdas that can scale together with their services.
Using Nest you are not able to use any of that.
If you use Nest, you wont need any of the SST stuff, better use CDK to crate k8s resources like EKS.
@Adrián Mouly thanks, I think you are right, the only reason I am considering nestjs is that I like the architecture there, my app currently uses DDD + CQRS and events and it has a very nice dev experience IMO, currently I wrote most of the surrounding architecture around my commands/queries/events and it is working well I just hoped to have something that I can replace my code with (less code for me to manage 😂)
But I think you are right it does look like it is making my apps very bloated and I loose the single responsibility lambdas
you could still have 1 lambda be 1 module with 1 controller that serves 1 API endpoint but why have all the unnecessary bloat
Exactly, you can do it, but that’s not the purpose behind Nest.