Bläddra i källkod

新增 sendError云函数

wangzhihui 4 år sedan
förälder
incheckning
8f83a980b6
1 ändrade filer med 14 tillägg och 1 borttagningar
  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) => {