All Projects → fastify → Aws Lambda Fastify

fastify / Aws Lambda Fastify

Licence: mit
Insipired by aws-serverless-express to work with Fastify with inject functionality.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Aws Lambda Fastify

Serverless Es Logs
A Serverless plugin to transport logs to ElasticSearch
Stars: ✭ 51 (-73.16%)
Mutual labels:  api, api-gateway, aws, serverless, lambda
Up
Up focuses on deploying "vanilla" HTTP servers so there's nothing new to learn, just develop with your favorite existing frameworks such as Express, Koa, Django, Golang net/http or others.
Stars: ✭ 8,439 (+4341.58%)
Mutual labels:  api, api-gateway, aws, serverless, lambda
Shep
A framework for building JavaScript Applications with AWS API Gateway and Lambda
Stars: ✭ 376 (+97.89%)
Mutual labels:  api-gateway, aws, serverless, lambda, amazon
Aws Mobile React Sample
A React Starter App that displays how web developers can integrate their front end with AWS on the backend. The App interacts with AWS Cognito, API Gateway, Lambda and DynamoDB on the backend.
Stars: ✭ 650 (+242.11%)
Mutual labels:  api-gateway, aws, serverless, lambda
Webiny Js
Enterprise open-source serverless CMS. Includes a headless CMS, page builder, form builder and file manager. Easy to customize and expand. Deploys to AWS.
Stars: ✭ 4,869 (+2462.63%)
Mutual labels:  aws, serverless, cloud, lambda
Aws Sam Cli
CLI tool to build, test, debug, and deploy Serverless applications using AWS SAM
Stars: ✭ 5,817 (+2961.58%)
Mutual labels:  api-gateway, aws, serverless, lambda
Cloud Custodian
Rules engine for cloud security, cost optimization, and governance, DSL in yaml for policies to query, filter, and take actions on resources
Stars: ✭ 3,926 (+1966.32%)
Mutual labels:  aws, serverless, cloud, lambda
Terraform Nextjs Plugin
A plugin to generate terraform configuration for Nextjs 8 and 9
Stars: ✭ 41 (-78.42%)
Mutual labels:  api-gateway, aws, serverless, lambda
Aws Toolkit Vscode
AWS Toolkit for Visual Studio Code, an extension for working with AWS services including AWS Lambda.
Stars: ✭ 823 (+333.16%)
Mutual labels:  aws, serverless, lambda, amazon
Chalice
Python Serverless Microframework for AWS
Stars: ✭ 8,513 (+4380.53%)
Mutual labels:  aws, serverless, cloud, lambda
Awesome Aws
A curated list of awesome Amazon Web Services (AWS) libraries, open source repos, guides, blogs, and other resources. Featuring the Fiery Meter of AWSome.
Stars: ✭ 9,895 (+5107.89%)
Mutual labels:  aws, serverless, cloud, lambda
Mangum
AWS Lambda & API Gateway support for ASGI
Stars: ✭ 475 (+150%)
Mutual labels:  api-gateway, aws, serverless, lambda
Aws Serverless Ecommerce Platform
Serverless Ecommerce Platform is a sample implementation of a serverless backend for an e-commerce website. This sample is not meant to be used as an e-commerce platform as-is, but as an inspiration on how to build event-driven serverless microservices on AWS.
Stars: ✭ 469 (+146.84%)
Mutual labels:  api-gateway, aws, serverless, lambda
Serverless Next.js
⚡ Deploy your Next.js apps on AWS Lambda@Edge via Serverless Components
Stars: ✭ 2,977 (+1466.84%)
Mutual labels:  api-gateway, aws, serverless, lambda
Node Lambda Log
Basic logging mechanism for Node 6.10+ Lambda Functions
Stars: ✭ 115 (-39.47%)
Mutual labels:  aws, serverless, cloud, lambda
Workshop Donkeytracker
Workshop to build a serverless tracking application for your mobile device with an AWS backend
Stars: ✭ 27 (-85.79%)
Mutual labels:  api-gateway, aws, serverless, lambda
Apilogs
Easy logging and debugging for Amazon API Gateway and AWS Lambda Serverless APIs
Stars: ✭ 216 (+13.68%)
Mutual labels:  api, api-gateway, aws, lambda
Aws Auto Cleanup
Open-source application to programmatically clean your AWS resources based on a whitelist and time to live (TTL) settings
Stars: ✭ 276 (+45.26%)
Mutual labels:  aws, serverless, cloud, lambda
Aws Serverless Java Container
A Java wrapper to run Spring, Jersey, Spark, and other apps inside AWS Lambda.
Stars: ✭ 1,054 (+454.74%)
Mutual labels:  api, api-gateway, aws, serverless
Json Serverless
Transform a JSON file into a serverless REST API in AWS cloud
Stars: ✭ 108 (-43.16%)
Mutual labels:  api, aws, serverless, lambda

Introduction

travis npm

Inspired by the AWSLABS aws-serverless-express library tailor made for the Fastify web framework.

No use of internal sockets, makes use of Fastify's inject function.

Seems faster (as the name implies) than aws-serverless-express and aws-serverless-fastify 😉

👨🏻‍💻Installation

$ npm install aws-lambda-fastify

📖Example

lambda.js

const awsLambdaFastify = require('aws-lambda-fastify')
const app = require('./app')

const proxy = awsLambdaFastify(app)
// or
// const proxy = awsLambdaFastify(app, { binaryMimeTypes: ['application/octet-stream'] })

exports.handler = proxy
// or
// exports.handler = (event, context, callback) => proxy(event, context, callback)
// or
// exports.handler = (event, context) => proxy(event, context)
// or
// exports.handler = async (event, context) => proxy(event, context)

app.js

const fastify = require('fastify')

const app = fastify()
app.get('/', (request, reply) => reply.send({ hello: 'world' }))

if (require.main === module) {
  // called directly i.e. "node app"
  app.listen(3000, (err) => {
    if (err) console.error(err)
    console.log('server listening on 3000')
  })
} else {
  // required as a module => executed on aws lambda
  module.exports = app
}

When executed in your lambda function we don't need to listen to a specific port, so we just export the app in this case. The lambda.js file will use this export.

When you execute your Fastify application like always, i.e. node app.js (the detection for this could be require.main === module), you can normally listen to your port, so you can still run your Fastify function locally.

📣Hint

The original lambda event and context are passed via headers and can be used like this:

app.get('/', (request, reply) => {
  const event = JSON.parse(decodeURIComponent(request.headers['x-apigateway-event']))
  const context = JSON.parse(decodeURIComponent(request.headers['x-apigateway-context']))
  // ...
})

⚡️Some basic performance metrics

aws-lambda-fastify x 28,189 ops/sec ±4.59% (79 runs sampled)

serverless-http x 20,975 ops/sec ±4.65% (79 runs sampled)

aws-serverless-fastify x 4,042 ops/sec ±2.14% (75 runs sampled)

aws-serverless-express x 3,558 ops/sec ±4.48% (71 runs sampled)

Fastest is aws-lambda-fastify

⚠️Considerations

  • For apps that may not see traffic for several minutes at a time, you could see cold starts
  • Stateless only
  • API Gateway has a timeout of 29 seconds, and Lambda has a maximum execution time of 15 minutes. (Using Application Load Balancer has no timeout limit, so the lambda maximum execution time is relevant)
  • If you are using another web framework (Connect, Express, Koa, Restana, Sails, Hapi, Fastify, Restify) or want to use a more generic serverless proxy framework, have a look at: serverless-http

🎖Who is using it?

locize is using aws-lambda-fastify
localistars is using aws-lambda-fastify

The logos displayed in this page are property of the respective organisations and they are not distributed under the same license as aws-lambda-fastify (MIT).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].