auth-core-dashboard.ts36 lines · main
| 1 | /** |
| 2 | * Yellow Authentication dashboard aggregate (Doltgres). |
| 3 | * |
| 4 | * GET /v1/auth-core/dashboard — counts + recent users + methods |
| 5 | * Requires platform dashboard session. |
| 6 | */ |
| 7 | |
| 8 | import { Hono } from 'hono'; |
| 9 | |
| 10 | import { requireAuthCoreDashboard } from '../middleware/auth-core-guard.js'; |
| 11 | import { getBrivenEngineDashboard } from '../services/auth-core/dashboard.js'; |
| 12 | import type { AppEnv } from '../types/app-env.js'; |
| 13 | |
| 14 | export const authCoreDashboardRouter = new Hono<AppEnv>(); |
| 15 | |
| 16 | authCoreDashboardRouter.use( |
| 17 | '/v1/auth-core/dashboard', |
| 18 | requireAuthCoreDashboard(), |
| 19 | ); |
| 20 | |
| 21 | authCoreDashboardRouter.get('/v1/auth-core/dashboard', async (c) => { |
| 22 | const projectId = c.req.query('projectId') ?? undefined; |
| 23 | let tenantId = c.req.query('tenantId') ?? undefined; |
| 24 | if (!tenantId && projectId) { |
| 25 | try { |
| 26 | const { projectIdToTenantId } = await import( |
| 27 | '../services/auth-core/project-map.js' |
| 28 | ); |
| 29 | tenantId = projectIdToTenantId(projectId); |
| 30 | } catch { |
| 31 | tenantId = undefined; |
| 32 | } |
| 33 | } |
| 34 | const data = await getBrivenEngineDashboard({ projectId, tenantId }); |
| 35 | return c.json(data); |
| 36 | }); |