Openstatus www.openstatus.dev

✨ enhance run monitor error handling and update payload structure

+8 -5
+8 -5
apps/server/src/v1/monitors/run/post.ts
··· 109 109 .array(selectMonitorStatusSchema) 110 110 .safeParse(monitorStatusData); 111 111 if (!monitorStatus.success) { 112 + console.log(monitorStatus.error); 112 113 throw new HTTPException(400, { message: "Something went wrong" }); 113 114 } 114 115 ··· 140 141 // 141 142 if (row.jobType === "http") { 142 143 payload = { 143 - workspaceId: "1", 144 - monitorId: "2260", 145 - url: "https://www.openstatus.dev/api/ping/edge", 144 + workspaceId: String(row.workspaceId), 145 + monitorId: String(row.id), 146 + url: row.url, 146 147 method: row.method || "GET", 147 148 cronTimestamp: timestamp, 148 149 body: row.body, ··· 176 177 headers: { 177 178 "Content-Type": "application/json", 178 179 "fly-prefer-region": region, // Specify the region you want the request to be sent to 179 - Authorization: "Basic ILoveCronJobs", 180 + Authorization: `Basic ${env.CRON_SECRET}`, 180 181 }, 181 182 method: "POST", 182 183 body: JSON.stringify(payload), ··· 189 190 } 190 191 191 192 const result = await Promise.all(allResult); 193 + // console.log(result); 192 194 193 195 const bodies = await Promise.all(result.map((r) => r.json())); 196 + console.log(bodies); 194 197 const data = z.array(HTTPTriggerResult).safeParse(bodies); 195 198 196 199 if (!data.success) { 197 - console.error(data.error); 200 + console.log(data.error); 198 201 throw new HTTPException(400, { message: "Something went wrong" }); 199 202 } 200 203