Nestjs AWS Serverless
About
@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
👨🏻💻Installation
Install the main lib
npm install --save @gcoreplus/nestjs-aws-serverless
Install the libs for your favorite engine
Express
npm install --save @nestjs/platform-express
npm install --save aws-serverless-express
Fastify
npm install --save @nestjs/platform-fastify
npm install --save aws-serverless-fastify
Create the aws handler
Create a file (e.g. main-aws.ts
) to boot your app on lambda
Express
import { lambda } from '@gcoreplus/nestjs-aws-serverless';
import { AppModule } from './app.module';
export const handler = lambda(AppModule);
Fastify
import { lambda } from '@gcoreplus/nestjs-aws-serverless';
import { AppModule } from './app.module';
export const handler = lambda(AppModule, {engine: 'fastify'});
Deploy
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
...
Options
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 |
Examples
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
Backers
License
Distributed under the ISC License. See LICENSE
for more information.
Acknowledgements
Copyright © 2020 gCorePlus Inc.