refactor: migrate to Tencent Cloud backend

这个提交包含在:
Guoguo
2026-04-28 22:56:47 +08:00
父节点 267c75718b
当前提交 444c91c0b0
修改 102 个文件,包含 17927 行新增1997 行删除
+34
查看文件
@@ -0,0 +1,34 @@
const Router = require('./lib/router')
const { createContext } = require('./lib/request')
const { ok, fail, http } = require('./lib/response')
const router = new Router()
require('./routes/auth')(router)
require('./routes/user')(router)
require('./routes/device')(router)
require('./routes/subscription')(router)
require('./routes/treatment')(router)
require('./routes/admin')(router)
require('./routes/firmware')(router)
async function handle(event) {
const ctx = createContext(event || {})
if (ctx.method === 'OPTIONS') return http(204, {})
if (ctx.path === '/health') return http(200, ok({ status: 'ok' }))
const match = router.match(ctx.method, ctx.path)
if (!match) return http(404, fail(404, 'not_found'))
ctx.params = match.params
try {
const body = await match.handler(ctx)
return http(200, body)
} catch (err) {
console.error(err)
return http(500, fail(3001, 'server_error'))
}
}
module.exports = { handle }