Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Examples | 10,886 | 9 days ago | 19 | April 25, 2021 | 170 | other | JavaScript | |||
Serverless Examples – A collection of boilerplates and examples of serverless architectures built with the Serverless Framework on AWS Lambda, Microsoft Azure, Google Cloud Functions, and more. | ||||||||||
Caprover | 10,459 | a month ago | 100 | other | TypeScript | |||||
Scalable PaaS (automated Docker+nginx) - aka Heroku on Steroids | ||||||||||
Up | 8,687 | 68 | 13 | 3 months ago | 11 | March 02, 2018 | 291 | mit | Go | |
Deploy infinitely scalable serverless apps, apis, and sites in seconds to AWS. | ||||||||||
Midway | 6,668 | 3 | 147 | a day ago | 204 | August 16, 2022 | 134 | mit | TypeScript | |
🍔 A Node.js Serverless Framework for front-end/full-stack developers. Build the application for next decade. Works on AWS, Alibaba Cloud, Tencent Cloud and traditional VM/Container. Super easy integrate with React and Vue. 🌈 | ||||||||||
Webiny Js | 6,592 | 113 | a day ago | 251 | September 07, 2022 | 254 | other | TypeScript | ||
Open-source serverless enterprise CMS. Includes a headless CMS, page builder, form builder, and file manager. Easy to customize and expand. Deploys to AWS. | ||||||||||
Dev Setup | 5,802 | 9 months ago | 34 | other | Python | |||||
macOS development environment setup: Easy-to-understand instructions with automated setup scripts for developer tools like Vim, Sublime Text, Bash, iTerm, Python data analysis, Spark, Hadoop MapReduce, AWS, Heroku, JavaScript web development, Android development, common data stores, and dev-based OS X defaults. | ||||||||||
Serverless Express | 4,835 | 660 | 159 | 20 days ago | 33 | December 06, 2020 | 76 | apache-2.0 | JavaScript | |
Run Node.js web applications and APIs using existing application frameworks on AWS #serverless technologies such as Lambda, API Gateway, [email protected], and ALB. | ||||||||||
Grant | 3,771 | 210 | 41 | 6 months ago | 98 | March 09, 2022 | 23 | mit | JavaScript | |
OAuth Proxy | ||||||||||
Practicalnode | 3,765 | 4 months ago | 6 | JavaScript | ||||||
Practical Node.js, 1st and 2nd Editions [Apress] 📓 | ||||||||||
Claudia | 3,709 | 193 | 29 | a year ago | 122 | March 17, 2022 | 14 | mit | JavaScript | |
Deploy Node.js projects to AWS Lambda and API Gateway easily |
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 😉
$ npm i @fastify/aws-lambda
@fastify/aws-lambda can take options by passing them with : awsLambdaFastify(app, options)
property | description | default value |
---|---|---|
binaryMimeTypes | Array of binary MimeTypes to handle | [] |
enforceBase64 | Function that receives the response and returns a boolean indicating if the response content is binary or not and should be base64-encoded | undefined |
serializeLambdaArguments | Activate the serialization of lambda Event and Context in http header x-apigateway-event x-apigateway-context
|
false (was true for <v2.0.0)
|
decorateRequest | Decorates the fastify request with the lambda Event and Context request.awsLambda.event request.awsLambda.context
|
true |
decorationPropertyName | The default property name for request decoration | awsLambda |
callbackWaitsForEmptyEventLoop | See: Official Documentation | undefined |
const awsLambdaFastify = require('@fastify/aws-lambda')
const app = require('./app')
const proxy = awsLambdaFastify(app)
// or
// const proxy = awsLambdaFastify(app, { binaryMimeTypes: ['application/octet-stream'], serializeLambdaArguments: false /* default is true */ })
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)
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({ port: 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.
The original lambda event and context are passed via Fastify request and can be used like this:
app.get('/', (request, reply) => {
const event = request.awsLambda.event
const context = request.awsLambda.context
// ...
})
If you do not like it, you can disable this by setting the decorateRequest
option to false
.
Alternatively the original lambda event and context are passed via headers and can be used like this, if setting the serializeLambdaArguments
option to true
:
app.get('/', (request, reply) => {
const event = JSON.parse(decodeURIComponent(request.headers['x-apigateway-event']))
const context = JSON.parse(decodeURIComponent(request.headers['x-apigateway-context']))
// ...
})
Since AWS Lambda now enables the use of ECMAScript (ES) modules in Node.js 14 runtimes, you could lower the cold start latency when used with Provisioned Concurrency thanks to the top-level await functionality.
We can use this by calling the fastify.ready()
function outside of the Lambda handler function, like this:
import awsLambdaFastify from '@fastify/aws-lambda'
import app from './app.js'
export const handler = awsLambdaFastify(app)
await app.ready() // needs to be placed after awsLambdaFastify call because of the decoration: https://github.com/fastify/aws-lambda-fastify/blob/master/index.js#L9
Here you can find the approriate issue discussing this feature.
@fastify/aws-lambda (decorateRequest : false) x 56,892 ops/sec ±3.73% (79 runs sampled)
@fastify/aws-lambda x 56,571 ops/sec ±3.52% (82 runs sampled)
@fastify/aws-lambda (serializeLambdaArguments : true) x 56,499 ops/sec ±3.56% (76 runs sampled)
serverless-http x 45,867 ops/sec ±4.42% (83 runs sampled)
aws-serverless-fastify x 17,937 ops/sec ±1.83% (86 runs sampled)
aws-serverless-express x 16,647 ops/sec ±2.88% (87 runs sampled)
Fastest is @fastify/aws-lambda (decorateRequest : false), @fastify/aws-lambda
The logos displayed in this page are property of the respective organisations and they are not distributed under the same license as @fastify/aws-lambda (MIT).