Efficient NestJS for small API. Terraform with remote state setup for deploying to AWS Lambda.
Folder | Purpose |
---|---|
(root) | API. Initialized with NestJS |
./src/lambda.ts | Entry point for AWS Lambda |
./src/http-runnder.ts | local development entry point |
./infra | IaC to AWS |
./test | E2E tests |
./src | NestJS TypeScript codes |
./runners | Local development utils |
Use NestJS API for local development
npm run start
&npm run start:debug
starts the NestJS API onlocalhost:3000
- Use
npm run start:debug
with VSCode LauncherAttach NestJS
to debug using VS Code breakpoints runners/POST-zoo.rest
- sample post requestsrunners/events
- partial data taken from AWS Lambda cloudwatch. Can be used to invoke thesrc/lambda.ts
-handler
method
Read the readme.md
on ./infra
.
- Utilize lazy-loading module pattern to reduce startup time.
- Study the
src/domains
examples.zoo
is eagerly loaded whiledogs
andcats
are lazy loaded. src/factories/lazy-module.factory.ts
simplifies the lazy-module initialization and caching.
- Study the
- Webpack is not advisable as per reason mentioned on ZenSoftware/bundled-nest
... INFO #perf bootup time: 4.315s
... INFO #perf handler time: 61.218ms
... INFO #perf handler time: 0.761ms
... INFO #perf handler time: 0.668ms
... INFO #perf handler time: 0.749ms
https://docs.nestjs.com/faq/serverless#serverless
https://github.com/estevaodias/demo-terraform-nestjs-aws-lambda/tree/develop/ci
Special thanks to the authors