Giter Site home page Giter Site logo

aglex's Issues

`req.url` not being set

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.

wish: compare to express-on-serverless

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:

  • zip -r lambda.zip app.js lambda.js routes views node_modules
  • aglex --config aglex.yml lambda update --zip lambda.zip
  • aglex --config aglex.yml apigateway update
  • aglex --config aglex.yml apigateway deploy --stage dev

With express-on-serverless, it's just one easy to remember command:

  • serverless deploy

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.

Wish: default to Node 4.3 environment

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.

Following Quick start guide throws: "Error: Cannot find module './apiGateway/restApi'"

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.