Skip to content

Commit

Permalink
🐛 test checker
Browse files Browse the repository at this point in the history
  • Loading branch information
thibaultleouay committed Sep 16, 2024
1 parent 11a0d52 commit 99b5373
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions apps/web/src/components/ping-response-analysis/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function continentFormatter(region: MonitorFlyRegion) {

export function regionFormatter(
region: MonitorFlyRegion,
type: "short" | "long" = "short",
type: "short" | "long" = "short"
) {
const { code, flag, location } = flyRegionsDict[region];
if (type === "short") return `${code} ${flag}`;
Expand Down Expand Up @@ -103,14 +103,14 @@ export const checkerSchema = z.object({
status: z.number(),
latency: z.number(),
headers: z.record(z.string()),
time: z.number(),
timestamp: z.number(),
timing: timingSchema,
body: z.string().optional().nullable(),
});

export const cachedCheckerSchema = z.object({
url: z.string(),
time: z.number(),
timestamp: z.number(),
method: z.enum(["GET", "POST", "PUT", "DELETE"]).default("GET"),
checks: checkerSchema.extend({ region: monitorFlyRegionSchema }).array(),
});
Expand All @@ -132,7 +132,7 @@ export async function checkRegion(
method?: Method;
headers?: { value: string; key: string }[];
body?: string;
},
}
): Promise<RegionChecker> {
//
const res = await fetch(`https://checker.openstatus.dev/ping/${region}`, {
Expand Down Expand Up @@ -166,7 +166,7 @@ export async function checkRegion(
if (!data.success) {
console.log(json);
console.error(
`something went wrong with result ${json} request to ${url} error ${data.error.message}`,
`something went wrong with result ${json} request to ${url} error ${data.error.message}`
);
throw new Error(data.error.message);
}
Expand All @@ -188,7 +188,7 @@ export async function checkAllRegions(url: string, opts?: { method: Method }) {
// REMINDER: dropping the body to avoid storing it within Redis Cache (Err max request size exceeded)
check.body = undefined;
return check;
}),
})
);
}

Expand Down

0 comments on commit 99b5373

Please sign in to comment.