如何从Cloud Functions Shell中的Express路由器访问终结点

(注意:我使用的是JavaScript,而不是函数中的打字稿)

我的Firebase项目具有一个“ oauth”功能,该功能具有通过快速应用程序/路由器创建的一系列端点。

我不了解如何在Cloud Functions Shell中在这些端点上运行功能以在本地调试它们。

这是我的index.js

const twitter = require("./oauth/twitter");
const app = express();
app.use("/signin/twitter",twitter.router);
exports.oauth = functions.https.onRequest(app);

我的实际端点位于twitter.js文件中(其他端点用于其他提供商)

router.get("/authorize",(req,res) => {...});
router.get("/authorize_callback",res) => {...});
router.get("/deauthorize",res) => {...});

如果我在终端中运行“ firebase functions:shell”,则仅显示“ oauth”功能。

我想像部署后在浏览器中一样访问“ oauth / signin / twitter / authorize”之类的功能,但是我不知道该怎么做!

这可能吗?

gaohhxx2009 回答:如何从Cloud Functions Shell中的Express路由器访问终结点

我相信这是您要寻找的documentation。本质上,您可以通过在Shell中的Cloud Function中调用方法(get,post等)来调用类似 express 的路由,例如:functionName.get('/test')

本文链接:https://www.f2er.com/3128461.html

大家都在问