Openstatus www.openstatus.dev
6
fork

Configure Feed

Select the types of activity you want to include in your feed.

🔥 improve returning data (#1072)

* 🔥 improve returning data

* ci: apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>

authored by

Thibault Le Ouay
autofix-ci[bot]
and committed by
GitHub
30aa303d 9b25a0da

+24 -30
-1
apps/server/src/v1/monitors/put.ts
··· 46 46 const { id } = c.req.valid("param"); 47 47 const input = c.req.valid("json"); 48 48 49 - console.log("input", input); 50 49 if (!limits.periodicity.includes(input.periodicity)) { 51 50 throw new HTTPException(403, { message: "Forbidden" }); 52 51 }
+24 -28
apps/server/src/v1/monitors/results/get.ts
··· 42 42 200: { 43 43 content: { 44 44 "application/json": { 45 - schema: z.object({ 46 - data: z.array( 47 - z.object({ 48 - latency: z.number().int(), // in ms 49 - statusCode: z.number().int().nullable().default(null), 50 - monitorId: z.string().default(""), 51 - url: z.string().url().optional(), 52 - error: z 53 - .number() 54 - .default(0) 55 - .transform((val) => val !== 0), 56 - region: z.enum(flyRegions), 57 - timestamp: z.number().int().optional(), 58 - message: z.string().nullable().optional(), 59 - timing: z 60 - .string() 61 - .nullable() 62 - .optional() 63 - .transform((val) => { 64 - if (!val) return null; 65 - const value = timingSchema.safeParse(JSON.parse(val)); 66 - if (value.success) return value.data; 67 - return null; 68 - }), 69 - }), 70 - ), 71 - }), 45 + schema: z.array( 46 + z.object({ 47 + latency: z.number().int(), // in ms 48 + statusCode: z.number().int().nullable().default(null), 49 + monitorId: z.string().default(""), 50 + url: z.string().url().optional(), 51 + error: z 52 + .number() 53 + .default(0) 54 + .transform((val) => val !== 0), 55 + region: z.enum(flyRegions), 56 + timestamp: z.number().int().optional(), 57 + message: z.string().nullable().optional(), 58 + timing: z 59 + .preprocess((val) => { 60 + if (!val) return null; 61 + const value = timingSchema.safeParse(JSON.parse(String(val))); 62 + if (value.success) return value.data; 63 + return null; 64 + }, timingSchema.nullable()) 65 + .optional(), 66 + }), 67 + ), 72 68 }, 73 69 }, 74 70 description: "All the metrics for the monitor", ··· 117 113 if (!data) { 118 114 throw new HTTPException(404, { message: "Not Found" }); 119 115 } 120 - return c.json({ data }, 200); 116 + return c.json(data, 200); 121 117 }); 122 118 }
-1
apps/server/src/v1/monitors/schema.ts
··· 170 170 }), 171 171 assertions: z 172 172 .preprocess((val) => { 173 - console.log("val", val); 174 173 try { 175 174 if (Array.isArray(val)) return val; 176 175 if (String(val).length > 0) {