teifip / gcf-api-router Goto Github PK
View Code? Open in Web Editor NEWExpress-style API router for Google Cloud Functions
License: MIT License
Express-style API router for Google Cloud Functions
License: MIT License
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"
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.
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.