Selaa lähdekoodia

新增 sendError云函数

wangzhihui 4 vuotta sitten
vanhempi
commit
8f83a980b6
1 muutettua tiedostoa jossa 14 lisäystä ja 1 poistoa
  1. 14 1
      cloudfunctions/api/index.js

+ 14 - 1
cloudfunctions/api/index.js

@@ -9,7 +9,8 @@ const WXBizDataCrypt = require('./WXBizDataCrypt')
 
 cloud.init()
 
-
+const db = cloud.database()
+const errorLogs = db.collection("huihenduo_error_log")
 
 // 云函数入口函数
 exports.main = async (event, context) => {
@@ -55,6 +56,18 @@ exports.main = async (event, context) => {
     }
     await next()
   })
+  app.router("sendError", async (ctx, next) => {
+    delete event.$url
+    delete event.userInfo
+    let res = await errorLogs.add({
+      data: {
+        createTime: db.serverDate(),
+        ...event,
+        _openid,
+      }
+    })
+    await next()
+  })
 
   app.router("base", async (ctx, next) => {