1.1.1 • Published 6 years ago

aws-serverless-express-edge v1.1.1

Weekly downloads
38
License
Apache-2.0
Repository
github
Last release
6 years ago

Run serverless applications on the edge in Amazon CloudFront by leveraging Lambda@Edge. This is especially useful for deporting the intensive task of server rendering SPAs to AWS Lambda, which will let you scale to 100 reqs/s painlessly all the while leveraging CloudFront's edge cache.

Limits on Lambda@Edge.

Getting Started

npm install aws-serverless-express-edge
// lambda.js
'use strict'
const awsServerlessExpress = require('aws-serverless-express-edge')
const app = require('./app')
const server = awsServerlessExpress.createServer(app)

exports.handler = (event, context) => awsServerlessExpress.proxy(server, event, context)

Package and create your Lambda function, deploy the function in us-east-1, then link it to a CloudFront distribution as an Origin Request.

:warning: It is strongly recommended to serve assets from another distribution.

Quick Start/Example

TODO

Getting the Edge event object

This package includes middleware to easily get the event object Lambda receives from API Gateway

const awsServerlessExpressMiddleware = require('aws-serverless-express-edge/middleware')
app.use(awsServerlessExpressMiddleware.eventContext())
app.get('/', (req, res) => {
  res.json(req.edge.event)
})