2025-11-06 13:26:30 +09:00
|
|
|
import { Controller, Get } from "@nestjs/common";
|
2025-12-10 16:08:34 +09:00
|
|
|
import { CatalogCacheService } from "./services/catalog-cache.service.js";
|
|
|
|
|
import type { CatalogCacheSnapshot } from "./services/catalog-cache.service.js";
|
|
|
|
|
import { Public } from "@bff/modules/auth/decorators/public.decorator.js";
|
2025-11-06 16:32:29 +09:00
|
|
|
|
|
|
|
|
interface CatalogCacheHealthResponse {
|
|
|
|
|
timestamp: string;
|
|
|
|
|
metrics: CatalogCacheSnapshot;
|
|
|
|
|
ttl: {
|
|
|
|
|
catalogSeconds: number | null;
|
|
|
|
|
eligibilitySeconds: number | null;
|
|
|
|
|
staticSeconds: number | null;
|
|
|
|
|
volatileSeconds: number;
|
|
|
|
|
};
|
|
|
|
|
}
|
2025-11-06 13:26:30 +09:00
|
|
|
|
|
|
|
|
@Controller("health/catalog")
|
2025-12-01 15:30:04 +09:00
|
|
|
@Public()
|
2025-11-06 13:26:30 +09:00
|
|
|
export class CatalogHealthController {
|
|
|
|
|
constructor(private readonly catalogCache: CatalogCacheService) {}
|
|
|
|
|
|
|
|
|
|
@Get("cache")
|
2025-11-06 16:32:29 +09:00
|
|
|
getCacheMetrics(): CatalogCacheHealthResponse {
|
|
|
|
|
const ttl = this.catalogCache.getTtlConfiguration();
|
2025-11-06 13:26:30 +09:00
|
|
|
return {
|
|
|
|
|
timestamp: new Date().toISOString(),
|
|
|
|
|
metrics: this.catalogCache.getMetrics(),
|
2025-11-06 16:32:29 +09:00
|
|
|
ttl,
|
2025-11-06 13:26:30 +09:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|