YoruNoHikage / apex-api-gateway

Create and deploy your Apex project on AWS API Gateway using Swagger configuration
MIT License
19 stars 4 forks source link

cannot run update function #4

Closed id0Sch closed 7 years ago

id0Sch commented 8 years ago

Hi, first of , yesterday everything worked so I'm not quite sure why it stopped but anyways

apex-api-gateway update

Options:
  --help    Show help                                                  [boolean]
  --stdout  Output swagger to console without deploying

Cannot match against 'undefined' or 'null'.

what should i do? seems like yargs is the one to make it a no go...

YoruNoHikage commented 8 years ago

Wow, don't you have a more explicit error? What is your configuration?

id0Sch commented 8 years ago

nope, that's the error :) btw, it worked before so i'm not sure what changed...

another request: can you also include a CORS example in your readme? and is there a way to declare a path that has no lambda behind it? like the OPTIONS path that's needed sometimes?

thanks alot!

"x-api-gateway": {
    "base_path": "/dev",
    "stage_name": "dev",
    "rest-api-id": "xxx",
    "swagger-func-template": {
      "consumes": [
        "application/json"
      ],
      "produces": [
        "application/json"
      ],
      "responses": {
        "200": {
          "description": "200 response"
        },
        "400": {
          "description": "400 response"
        }
      },
      "x-amazon-apigateway-integration": {
        "responses": {
          "default": {
            "statusCode": "200"
          },
          "(.*)(Error|Exception|errorMessage)(.*)": {
            "statusCode": "400"
          }
        },
        "requestTemplates": {
          "application/json": "{\n   \"method\": \"$context.httpMethod\",\n   \"body\" : $input.json('$'),\n   \"headers\": {\n     #foreach($param in $input.params().header.keySet())\n     \"$param\": \"$util.escapeJavaScript($input.params().header.get($param))\" #if($foreach.hasNext),#end\n \n     #end\n   },\n   \"queryParams\": {\n     #foreach($param in $input.params().querystring.keySet())\n     \"$param\": \"$util.escapeJavaScript($input.params().querystring.get($param))\" #if($foreach.hasNext),#end\n \n     #end\n   },\n   \"pathParams\": {\n     #foreach($param in $input.params().path.keySet())\n     \"$param\": \"$util.escapeJavaScript($input.params().path.get($param))\" #if($foreach.hasNext),#end\n \n     #end\n   }\n}"
        },
        "uri": "arn:aws:apigateway:ap-southeast-2:lambda:path/2015-03-31/functions/arn:aws:lambda:ap-southeast-2:xxx:function:{{functionName}}/invocations",
        "passthroughBehavior": "when_no_match",
        "httpMethod": "{{functionMethod}}",
        "type": "aws"
      },
      "x-amazon-apigateway-auth": {
        "type": "none"
      }
    }
  }
id0Sch commented 8 years ago

ok so this PR fixes it https://github.com/YoruNoHikage/apex-api-gateway/pull/5 i had a .DS_STORE directory in functions so the bad require crashed it

YoruNoHikage commented 8 years ago

You can check out the "Adding CORS" section to my blog post about it : http://blog.yorunohikage.fr/2016/08/25/rest-api-made-easy-with-apex-aws-lambda-and-aws-api-gateway/. Using paths property, you can add OPTIONS method, but for now there is no way to add paths that is not tight to a lambda function.

Thanks for the PR, I'll look into it! :)

id0Sch commented 8 years ago

that blog was exactly what i was missing! thanks! btw, why apex and not serverless? ( im POC'ing lambda and im trying to find the best stack) seems like serverless has apigateway integration built in