dougmoscrop / serverless-http

Use your existing middleware framework (e.g. Express, Koa) in AWS Lambda 🎉
Other
1.72k stars 166 forks source link

get context #129

Closed openainext closed 4 years ago

openainext commented 4 years ago

const serverless = require('serverless-http'); const Koa = require('koa'); // or any supported framework

const app = new Koa();

app.use(function(ctx){

//How ctx get context

});

// this is it! module.exports.handler = serverless(app);

// or as a promise const handler = serverless(app); module.exports.handler = async (event, context) => { // you can do other things here

const result = await handler(event, context); //context Where to go

// and here return result; };