This is an example of creating a function that runs as nestjs using the serverless framework. Sample publish. https://hello.magishift.com/
$ npm install @nestjs/cli serverless -g
$ git clone https://github.com/sofyan-ahmad/serverless-example-nestjs.git 【projectName】
$ cd 【projectName】
$ npm install
$ npm start
$ npm start
Then browse http://localhost:3000
after also doing an: npm run build
$ sls offline
Then browse http://localhost:3000
$ npm run build && sls deploy
See : https://serverless.com/blog/keep-your-lambdas-warm/
These behavior can be fixed with the plugin serverless-plugin-warmup
1 Install the plugin
$ npm install serverless-plugin-warmup --save-dev
2 Enable the plugin
plugins:
- serverless-offline
- serverless-dotenv-plugin
- serverless-domain-manager
- serverless-plugin-optimize
- serverless-pseudo-parameters
- serverless-plugin-warmup
custom:
# Enable warmup on all functions (only for production and staging)
warmup:
- production
- staging