@gcoreplus/nestjs-aws-serverless
TypeScript icon, indicating that this package has built-in type declarations

1.1.1-rc1 • Public • Published

npm version Codecov Coverage ISC license

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

Rennan Stefan Boni Paulo Márcio

License

Distributed under the ISC License. See LICENSE for more information.

Acknowledgements

Copyright © 2020 gCorePlus Inc.

Package Sidebar

Install

npm i @gcoreplus/nestjs-aws-serverless

Weekly Downloads

5

Version

1.1.1-rc1

License

ISC

Unpacked Size

17.4 kB

Total Files

6

Last publish

Collaborators

  • rennanboni