@gCorePlus/nestjs-aws-serverless
provide easy way to run Nest.js on AWS Lambda using express or fastify engines
Inspired by the aws-serverless-express and aws-lambda-fastify library
Install the main lib
npm install --save @gcoreplus/nestjs-aws-serverless
Install the libs for your favorite engine
npm install --save @nestjs/platform-express
npm install --save aws-serverless-express
npm install --save @nestjs/platform-fastify
npm install --save aws-serverless-fastify
Create a file (e.g. main-aws.ts
) to boot your app on lambda
import { lambda } from '@gcoreplus/nestjs-aws-serverless';
import { AppModule } from './app.module';
export const handler = lambda(AppModule);
import { lambda } from '@gcoreplus/nestjs-aws-serverless';
import { AppModule } from './app.module';
export const handler = lambda(AppModule, {engine: 'fastify'});
Deploy your app on AWS Lambda with serverless or setup manually pointing to main-aws.ts
as main-aws.handler
see example from express or fastify
...
functions:
hello-world:
name: ${self:custom.prefix-name}
handler: dist/test/nestjs-aws-serverless-express/src/main-aws.handler
...
Name | Description |
---|---|
engine | Engine name to be use express or fastify . Default value express |
warmup.source | Check for aws event source (context.source === warmup.source ), if equal it will return string Lambda is warm! . See serverless-plugin-warmup |
fastify.options | Fastify options. See options |
fastify.binaryTypes | List of binaries for Fastify. See aws-lambda-fastify |
nestjs.options | NestJs application options. See NestApplicationOptions |
nestjs.onBeforeInit | Function called before the app.init() is invoked |
nestjs.onAfterInit | Function called after the app.init() is invoked |
Check the examples for express and fastify and deploy using the follow commands
npm install
npm run build
npm run deploy:test:us-east-1
Distributed under the ISC License. See LICENSE
for more information.
Copyright © 2020 gCorePlus Inc.