Deploy nestJS server as Serverless function

Hi,
anyone has experience with deploying a nestJs app as Netlify function?
I cannot get it working.

Anyone knows a demo/ example which could help me out?

I’ve tried to get it working with Netlify-lambda, custom webpack build config and wrap nestJs as a Serverless component based on express.

Thank you for any advice.
Greetings
Christopher

Hi Christopher,

I’ve never seen anyone do this, but if you want help then you should probably provide more details, including errors, code, links to your repo, explanations on what’s not working, etc.

Also, I’m curious why you want to run nestjs in your function?

Hi,

thanks for reply.
Regarding the why: Within my current project we created a nestJs based REST API which is enabled to be used as serverless function running in AWS. The approach worked really well. To get a kickstart for my side-projects I created a Monorepo boilerplate. I was running a vuejs ui and an express based api which all could be easily deployed to Netlify so that I do not waste any energy in setup and could start right away with realizing my ideas. I changed the stack now to Angular and NestJs and want to have the same approach but with that frameworks, here is the repo: https://github.com/ChristopherNeuwirth/prototype-starter. Currently I made it work with deploying the ui still to Netlify and the api to zeit.co but I would love to just use Netlify.

Within my previous stack with express I wrapped the express instance into Serverless-http and I got it running: https://github.com/ChristopherNeuwirth/prototype-starter/blob/4e6aa47e2626099e60bd17737377cadc5cf2179f/api/src/express/server.ts. Due to some research and experience with in my project I tried the same with nestJs, like this commit illustrates: https://github.com/ChristopherNeuwirth/prototype-starter/blob/d6f97f4cafe579694a25784494ac28e718ef3872/api/src/index.ts

But so far I couldn’t figure out what piece I am missing since the deployments on Netlify just timed out after trying to upload the compiled code.

Unfortunately I deleted the Netlify Project but the error message just was: “Unable to upload”. The build process recognized functions in the source code in the build step before.

When I tried to make it work with custom webpack and Netlify-functions it all came up on my machine. The routes where not recognized but at least the default route returning hello world worked.

Thanks for your time and advice.
Greetings
Christopher

Hello @ChristopherNeuwirth,

I’m not too sure what caused the ‘unabled to upload’ without seeing the build logs for myself. However, since you mentioned deploying an express server, have you read through this article? Perhaps that might help you get things going.