import { inject, injectable } from "@codemation/core"; import type { Hono } from "hono"; import { ApplicationTokens } from "../applicationTokens"; import type { QueryBus } from "../application/bus/QueryBus"; import { GetWorkflowCredentialHealthQuery } from "../application/queries/GetWorkflowCredentialHealthQuery"; import { InternalHmacAuthMiddleware } from "../pairing/InternalHmacAuthMiddleware"; import type { InternalHonoApiRouteRegistrar } from "../presentation/http/hono/InternalHonoApiRouteRegistrar"; @injectable() export class InternalWorkflowCredentialHealthRegistrar implements InternalHonoApiRouteRegistrar { constructor( @inject(InternalHmacAuthMiddleware) private readonly hmacMiddleware: InternalHmacAuthMiddleware, @inject(ApplicationTokens.QueryBus) private readonly queryBus: QueryBus, ) {} register(app: Hono): void { app.get("/internal/workflows/:workflowId/credential-health", this.hmacMiddleware.handle(), async (c) => { const workflowId = c.req.param("workflowId"); const health = await this.queryBus.execute(new GetWorkflowCredentialHealthQuery(workflowId)); return c.json(health); }); } }