在 Express.js 中使用 Firebase 函数

Using Firebase Functions with Express.js

我正在编写一个接受来自 API 端点的输入的函数。但问题是当我现在想将记录插入数据库时​​。我立即在函数前添加 async,我得到一个 eslint 错误 Parsing Error: Unexpected token =>。因此,我无法部署该功能。另请查看随附的屏幕截图

app.post("/c2b/confirm", async (req, res) => {
  console.log("----------confirm-------------");
  console.log(JSON.stringify(req.body));
  const payment = admin.firestore().collection("payments").doc();
  await payment.set(req.body);
  res.status(200).json({"ResultCode": 0, "ResultDesc": "Success"});
});

exports.main = functions.https.onRequest(app);

这是一个 linter 错误。 请确保你的 eslintrc 中有这些:

{
  "env": {
    "node": true,
    "es6": true
  },

  "parserOptions": {
    "ecmaVersion": 8
  }
}