docs.nestjs.com icon indicating copy to clipboard operation
docs.nestjs.com copied to clipboard

docs(serverless): fixed broken example integration

Open H4ad opened this issue 1 year ago • 1 comments

PR Checklist

Please check if your PR fulfills the following requirements:

  • [x] The commit message follows our guidelines: https://github.com/nestjs/docs.nestjs.com/blob/master/CONTRIBUTING.md

PR Type

What kind of change does this PR introduce?

  • [ ] Bugfix
  • [ ] Feature
  • [ ] Code style update (formatting, local variables)
  • [ ] Refactoring (no functional changes, no api changes)
  • [ ] Build related changes
  • [x] Docs
  • [ ] Other... Please describe:

What is the current behavior?

Issue Number: #2142

What is the new behavior?

Current example integration with serverless is broken and also doesn't provide good default options to reduce package size or have good performance.

So I made some changes:

  • Changed the default file from main.ts to lambda.ts, as it makes no sense to build the app just for testing, I recommended keeping main.ts as is and creating lambda.ts with all the necessary code.
  • Fixed boilerplate for lambda.ts, the previous example didn't provide a simple fix that could improve cold start by up to a second.
  • Be clearer about serverless workflow, no need to build NestJS application every time we want to test.
  • Introduce some default extensions and folders to exclude by default to reduce package size.

I introduced NestJS in my company almost 3 years ago migrating from .NET, since then we have deployed serverless APIs using AWS Lambda, we have almost 100 Lambdas in two regions, each lambda being a NestJS API. This PR is a big thanks to the NestJS team and the community for maintaining this great framework that I love so much.

To be honest, I've never used framework serverless because it didn't work well for my company, I always use built-in tools (like this one) to zip the whole folder and then deploy the zip manually with aws cli. But I the documentation I still kept the serverless framework and added a tip about using npx serverless package instead of running npx serverless deploy.

Does this PR introduce a breaking change?

  • [ ] Yes
  • [x] No

Other information

I also have some questions:

  • Shouldn't serverless documentation be a folder inside NestJS docs? The current file for describing serverless documents seems to have a lot of noise because it talks about so many things. It will be better to have a folder and inside it we can cover things like: Optimizations, AWS, Azure, GCP, deep diving into specific libraries when using fastify or express, how to handle asynchronous jobs and many other things.
  • Shouldn't the examples in the docs be a project inside the packages folder?

H4ad avatar Jul 31 '22 19:07 H4ad

These changes seem to make this chapter more confusing & complicated.

kamilmysliwiec avatar Aug 01 '22 07:08 kamilmysliwiec