mirror of
https://github.com/fosrl/pangolin.git
synced 2026-05-05 12:04:14 +00:00
Transititioning the hc table and firing the alerts
This commit is contained in:
@@ -15,8 +15,8 @@ const getTargetSchema = z.strictObject({
|
||||
});
|
||||
|
||||
type GetTargetResponse = Target &
|
||||
Omit<TargetHealthCheck, "hcHeaders"> & {
|
||||
hcHeaders: { name: string; value: string }[] | null;
|
||||
Partial<Omit<TargetHealthCheck, "hcHeaders" | "targetId">> & {
|
||||
hcHeaders: { name: string; value: string }[] | null | undefined;
|
||||
};
|
||||
|
||||
registry.registerPath({
|
||||
@@ -70,20 +70,19 @@ export async function getTarget(
|
||||
.limit(1);
|
||||
|
||||
// Parse hcHeaders from JSON string back to array
|
||||
let parsedHcHeaders = null;
|
||||
let parsedHcHeaders: { name: string; value: string }[] | null = null;
|
||||
if (targetHc?.hcHeaders) {
|
||||
try {
|
||||
parsedHcHeaders = JSON.parse(targetHc.hcHeaders);
|
||||
} catch (error) {
|
||||
// If parsing fails, keep as string for backward compatibility
|
||||
parsedHcHeaders = targetHc.hcHeaders;
|
||||
// If parsing fails, keep as null for safety
|
||||
}
|
||||
}
|
||||
|
||||
return response<GetTargetResponse>(res, {
|
||||
data: {
|
||||
...target[0],
|
||||
...targetHc,
|
||||
...target[0],
|
||||
hcHeaders: parsedHcHeaders
|
||||
},
|
||||
success: true,
|
||||
|
||||
Reference in New Issue
Block a user