Coder Social home page Coder Social logo

gcf-api-router's People

Contributors

teifip avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

gcf-api-router's Issues

Optional parameters changed from undefined to "undefined"

pathToRegexp returns missing optional parameters as undefined,

gcf-api-router changes this to the string "undefined"

return decodeURIComponent(value); <- line 103 inside the function decode(value) {

turns undefined into "undefined"

Doesn't work with local emulator

The router seems to fail completely when used with the cloud functions local emulator. https://yarnpkg.com/en/package/@google-cloud/functions-emulator

The process of using the emulator is described here: https://cloud.google.com/functions/docs/emulator

Here's my terminal:

$ functions start
Starting Google Cloud Functions Emulator...
Google Cloud Functions Emulator STARTED
┌────────┬────────┬─────────┬────────────────────────────────────────────┐
│ Status │ Name   │ Trigger │ Resource                                   │
├────────┼────────┼─────────┼────────────────────────────────────────────┤
│ READY  │ status │ HTTP    │ http://localhost:8010/1/us-central1/status │
└────────┴────────┴─────────┴────────────────────────────────────────────┘

$ functions deploy status --trigger-http
Copying file://C:\Users\TALLPA~1\AppData\Local\Temp\us-central1-status-11344Y3fxYbpo6B5B.zip...
Waiting for operation to finish...done.
Deploying function......done.
Function status deployed.
┌────────────┬──────────────────────────────────────────────────────────────────────────────────────┐
│ Property   │ Value                                                                                │
├────────────┼──────────────────────────────────────────────────────────────────────────────────────┤
│ Name       │ status                                                                               │
├────────────┼──────────────────────────────────────────────────────────────────────────────────────┤
│ Trigger    │ HTTP                                                                                 │
├────────────┼──────────────────────────────────────────────────────────────────────────────────────┤
│ Resource   │ http://localhost:8010/1/us-central1/status                                           │
├────────────┼──────────────────────────────────────────────────────────────────────────────────────┤
│ Timeout    │ 60 seconds                                                                           │
├────────────┼──────────────────────────────────────────────────────────────────────────────────────┤
│ Local path │ D:\Projects\Personal\railtrack                                                       │
├────────────┼──────────────────────────────────────────────────────────────────────────────────────┤
│ Archive    │ file://C:\Users\TALLPA~1\AppData\Local\Temp\us-central1-status-11344Y3fxYbpo6B5B.zip │
└────────────┴──────────────────────────────────────────────────────────────────────────────────────┘

On visiting the URL specified, I get this JSON response:

{  
   "stack":"TypeError: Cannot read property 'charAt' of undefined\n    at findRequestHandlers (D:\\Projects\\Personal\\railtrack\\node_modules\\gcf-api-router\\index.js:87:28)\n    at RequestHandler.onRequest (D:\\Projects\\Personal\\railtrack\\node_modules\\gcf-api-router\\index.js:12:27)\n    at app.use (C:\\Users\\tallpants\\AppData\\Local\\Yarn\\config\\global\\node_modules\\@google-cloud\\functions-emulator\\src\\supervisor\\worker.js:130:11)\n    at Layer.handle [as handle_request] (C:\\Users\\tallpants\\AppData\\Local\\Yarn\\config\\global\\node_modules\\express\\lib\\router\\layer.js:95:5)\n    at trim_prefix (C:\\Users\\tallpants\\AppData\\Local\\Yarn\\config\\global\\node_modules\\express\\lib\\router\\index.js:317:13)\n    at C:\\Users\\tallpants\\AppData\\Local\\Yarn\\config\\global\\node_modules\\express\\lib\\router\\index.js:284:7\n    at Function.process_params (C:\\Users\\tallpants\\AppData\\Local\\Yarn\\config\\global\\node_modules\\express\\lib\\router\\index.js:335:12)\n    at next (C:\\Users\\tallpants\\AppData\\Local\\Yarn\\config\\global\\node_modules\\express\\lib\\router\\index.js:275:10)\n    at app.use (C:\\Users\\tallpants\\AppData\\Local\\Yarn\\config\\global\\node_modules\\@google-cloud\\functions-emulator\\src\\supervisor\\worker.js:102:7)\n    at Layer.handle [as handle_request] (C:\\Users\\tallpants\\AppData\\Local\\Yarn\\config\\global\\node_modules\\express\\lib\\router\\layer.js:95:5)",
   "message":"Cannot read property 'charAt' of undefined",
   "name":"TypeError"
}

But when actually deployed to Google Cloud, it works flawlessly.

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.