完成基础功能
Docker Build and Push / build-image (push) Successful in 3m1s

This commit is contained in:
cheney
2026-08-06 16:55:03 +08:00
parent 4d02439ecb
commit eddddc56ae
10 changed files with 381 additions and 56 deletions
+8 -15
View File
@@ -1,35 +1,28 @@
import { Router } from 'express'
import { prisma } from '../db.js'
import { authRequired } from '../middleware.js'
import { fetchServers, fetchHistory } from '../komari-client.js'
const router = Router()
router.use(authRequired)
// 服务器节点列表: 元数据 + 最新快照
// 服务器节点列表: 实时从 komari 拉取 (不落库)
router.get('/servers', async (_req, res, next) => {
try {
const rows = await prisma.serverNode.findMany({
orderBy: { name: 'asc' },
})
res.json({ items: rows })
const items = await fetchServers()
res.json({ items })
} catch (e) { next(e) }
})
// 节点时序: ?uuid=...&hours=24
// 节点时序: komari 保留最近 24h, 1 分钟粒度 (不落库)
router.get('/servers/:uuid/history', async (req, res, next) => {
try {
const hours = Math.min(Math.max(Number(req.query.hours) || 24, 1), 168)
const since = new Date(Date.now() - hours * 3600 * 1000)
const rows = await prisma.serverNodeHistory.findMany({
where: { uuid: req.params.uuid, period: { gte: since } },
orderBy: { period: 'asc' },
take: 2000,
})
res.json({ items: rows })
const items = await fetchHistory(req.params.uuid)
res.json({ items })
} catch (e) { next(e) }
})
// 服务健康列表
// 服务健康列表 (服务监控暂留空, 接口保留)
router.get('/services', async (_req, res, next) => {
try {
const rows = await prisma.serviceCheck.findMany({