upd: menu dashboard

Deskripsi:
- connected to database

No Issues
This commit is contained in:
2026-04-14 16:24:17 +08:00
parent a0cafbf2e2
commit f38081b1eb
2 changed files with 67 additions and 27 deletions

View File

@@ -154,18 +154,38 @@ export function createApp() {
})
// ─── Monitoring API ────────────────────────────────
.get('/api/dashboard/stats', () => ({
totalApps: 3,
newErrors: 185,
activeUsers: '24.5k',
trends: { totalApps: 1, newErrors: 12, activeUsers: 5.2 }
}))
.get('/api/dashboard/stats', async () => {
const newErrors = await prisma.bug.count({ where: { status: 'OPEN' } })
const users = await prisma.user.count()
return {
totalApps: 1,
newErrors: newErrors,
activeUsers: users,
trends: { totalApps: 0, newErrors: 12, activeUsers: 5.2 }
}
})
.get('/api/apps', () => [
{ id: 'desa-plus', name: 'Desa+', status: 'active', users: 12450, errors: 12, version: '2.4.1' },
// { id: 'e-commerce', name: 'E-Commerce', status: 'warning', users: 8900, errors: 45, version: '1.8.0' },
// { id: 'fitness-app', name: 'Fitness App', status: 'error', users: 3200, errors: 128, version: '0.9.5' },
])
.get('/api/dashboard/recent-errors', async () => {
const bugs = await prisma.bug.findMany({
take: 5,
orderBy: { createdAt: 'desc' }
})
return bugs.map(b => ({
id: b.id,
app: b.app,
message: b.description,
version: b.affectedVersion,
time: b.createdAt.toISOString(),
severity: b.status
}))
})
.get('/api/apps', async () => {
const desaPlusErrors = await prisma.bug.count({ where: { app: { in: ['desa-plus', 'desa_plus'] }, status: 'OPEN' } })
return [
{ id: 'desa-plus', name: 'Desa+', status: 'active', users: 12450, errors: desaPlusErrors, version: '2.4.1' },
]
})
.get('/api/apps/:appId', ({ params: { appId } }) => {
const apps = {