u-minor / aglex Goto Github PK
View Code? Open in Web Editor NEWAPI Gateway + Lambda + Express development tool
API Gateway + Lambda + Express development tool
I figured out how to deploy and update the API Gateway using this tool. However, when I try to access a resource, I get this failure:
{
errorMessage: "Cannot call method 'indexOf' of undefined",
errorType: "TypeError",
stackTrace: [
"Function.handle (/var/task/node_modules/express/lib/router/index.js:140:28)",
"EventEmitter.handle (/var/task/node_modules/express/lib/application.js:173:10)",
"app (/var/task/node_modules/express/lib/express.js:38:9)",
"exports.handler (/var/task/lambda.js:61:5)"
]
}
In looked in the express source code, and it's failing because req.url
is undefined, but Express expects that not to be the case.
I looked in API Gateway and found that a reasonable looking body mapping template was defined:
{
"method": "$context.httpMethod",
"remoteAddr": "$context.identity.sourceIp",
"stage": "$context.stage",
"path": "$context.resourcePath",
"headers": {
#foreach ($key in $input.params().header.keySet())
"$key": "$util.escapeJavaScript($input.params().header.get($key))",
#end
"User-Agent": "$context.identity.userAgent"
},
"pathParams": {
#foreach ($key in $input.params().path.keySet())
"$key": "$util.escapeJavaScript($input.params().path.get($key))"#if ($foreach.hasNext),#end
#end
},
"queryParams": {
#foreach ($key in $input.params().querystring.keySet())
"$key": "$util.escapeJavaScript($input.params().querystring.get($key))"#if ($foreach.hasNext),#end
#end
},
"body": $input.json('$')
}
I also looked in lambda.js
, and it does appear to set req.url
based on event.path
so I'm not yet clear where the bug is.
I'll look some more.
Since this project started, AWS has added the new "proxy" feature to "AWS Gateway" and the serverless
project has appeared as well. There's even a project called express on serverless that focuses on making Express easy on serverless
.
With aglex
there are several steps and a fair bit of syntax to remember for a basic deploy flow:
With express-on-serverless, it's just one easy to remember command:
Also, the README says that JSON must always be returned here, while express-on-serverless
does not have that restriction. It would be helpful if the docs clarified the benefits of using aglex
over serverless
.
Version 0.2.0 added support 'stages' and 'deploy' subcommands for apigateway. It would be helpful if these were documented in the quick guide in the README.
Thank you.
Currently the Lambda is being set to run in the Node 0.10 environment. Setting the default to Node 4.3 would be preferred to take advantage of newer syntax. Having a runtime
config option in the YAML file could be useful.
Thank your this module.
It looks useful and I would like to try it.
However, I get this error in the Quick Start steps:
$ aglex generate config >aglex.yml
module.js:327
throw err;
^
Error: Cannot find module './apiGateway/restApi'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/home/mark/.nvm/versions/node/v4.4.1/lib/node_modules/aglex/lib/apiGateway.js:3:15)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
A great user experience might be to expect that setup is done with a "Power User" account.
At this stage an IAM user would be created for the purpose of deploying to this API and a policy would be attached to it that restricts it to managing just the functions.
Publishing a sample IAM policy for others to use would also be helpful.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.