serverless-docker
Version:
This is a proof of concept to see if we can replicate Amazon API Gateway using docker images to run lambda
26 lines (20 loc) • 556 B
JavaScript
const getEvent = (region, stage, method, path, authorizationToken) => ({
type: 'TOKEN',
authorizationToken,
methodArn: `arn:aws:execute-api:${region}:<Account id>:<API id>/${stage}/${method}${path}`,
})
const authorize = (lambda, context, authorizationToken, log) => {
const http = context.http
const event = getEvent(
context.region,
context.stage,
http.method.toLowerCase(),
http.path,
authorizationToken
)
return lambda.invoke(http.authorizer.function, event, log)
}
module.exports = {
authorize,
}