Openstatus www.openstatus.dev
6
fork

Configure Feed

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

✨ improve error handling and updated payload structure for run endpoint

+12 -11
+12 -11
apps/server/src/v1/monitors/run/post.ts
··· 61 61 .where( 62 62 and( 63 63 eq(monitorRun.workspaceId, Number(workspaceId)), 64 - gte(monitorRun.createdAt, new Date(lastMonth)), 65 - ), 64 + gte(monitorRun.createdAt, new Date(lastMonth)) 65 + ) 66 66 ) 67 67 .all() 68 68 )[0].count; ··· 80 80 and( 81 81 eq(monitor.id, Number(id)), 82 82 eq(monitor.workspaceId, Number(workspaceId)), 83 - isNull(monitor.deletedAt), 84 - ), 83 + isNull(monitor.deletedAt) 84 + ) 85 85 ) 86 86 .get(); 87 87 ··· 109 109 .array(selectMonitorStatusSchema) 110 110 .safeParse(monitorStatusData); 111 111 if (!monitorStatus.success) { 112 - console.log(monitorStatus.error); 113 112 throw new HTTPException(400, { message: "Something went wrong" }); 114 113 } 115 114 ··· 141 140 // 142 141 if (row.jobType === "http") { 143 142 payload = { 144 - workspaceId: String(row.workspaceId), 145 - monitorId: String(row.id), 146 - url: row.url, 143 + workspaceId: "1", 144 + monitorId: "2260", 145 + url: "https://www.openstatus.dev/api/ping/edge", 147 146 method: row.method || "GET", 148 147 cronTimestamp: timestamp, 149 148 body: row.body, ··· 177 176 headers: { 178 177 "Content-Type": "application/json", 179 178 "fly-prefer-region": region, // Specify the region you want the request to be sent to 180 - Authorization: `Basic ${env.CRON_SECRET}`, 179 + Authorization: "Basic ILoveCronJobs", 181 180 }, 182 181 method: "POST", 183 182 body: JSON.stringify(payload), ··· 190 189 } 191 190 192 191 const result = await Promise.all(allResult); 193 - const data = z.array(HTTPTriggerResult).safeParse(result); 192 + 193 + const bodies = await Promise.all(result.map((r) => r.json())); 194 + const data = z.array(HTTPTriggerResult).safeParse(bodies); 194 195 195 196 if (!data.success) { 196 - console.log(data.error); 197 + console.error(data.error); 197 198 throw new HTTPException(400, { message: "Something went wrong" }); 198 199 } 199 200