问题
(Note: I'm using javascript, not typescript in my Functions)
My Firebase Project has a single 'oauth' function, which has a series of endpoints created through express app/routers.
I don't understand how to run the functions at these endpoints from the Cloud Functions Shell to debug them locally.
Here is my index.js
const twitter = require("./oauth/twitter");
const app = express();
app.use("/signin/twitter", twitter.router);
exports.oauth = functions.https.onRequest(app);
My actual endpoints are in a twitter.js file (and others for other providers)
router.get("/authorize", (req, res) => {...});
router.get("/authorize_callback", (req, res) => {...});
router.get("/deauthorize", (req, res) => {...});
If I run 'firebase functions:shell' in my terminal, it only shows the 'oauth' function.
I would like to access a function such as 'oauth/signin/twitter/authorize' just like I do in the browser after deploying, but I have no idea how to!
Is this possible?
回答1:
I believe this is the documentation you are looking for. Essentially, you can invoke those express-like routes by calling the method (get, post, etc.) within the Cloud Function in the shell like such: functionName.get('/test')
来源:https://stackoverflow.com/questions/58790706/how-to-access-endpoint-from-express-router-in-cloud-functions-shell