Openstatus www.openstatus.dev
6
fork

Configure Feed

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

✨ add run monitor endpoint with optional no-wait query parameter (#1074)

* ✨ add run monitor endpoint with optional no-wait query parameter

* 🔧 fix syntax errors in run monitor query conditions

authored by

Thibault Le Ouay and committed by
GitHub
96ab3150 d6334213

+19 -2
+2
apps/server/src/v1/monitors/index.ts
··· 8 8 import { registerPostMonitor } from "./post"; 9 9 import { registerPutMonitor } from "./put"; 10 10 import { registerGetMonitorResult } from "./results/get"; 11 + import { registerRunMonitor } from "./run/post"; 11 12 import { registerGetMonitorSummary } from "./summary/get"; 12 13 import { registerTriggerMonitor } from "./trigger/post"; 13 14 ··· 23 24 registerPostMonitor(monitorsApi); 24 25 registerTriggerMonitor(monitorsApi); 25 26 registerGetMonitorResult(monitorsApi); 27 + registerRunMonitor(monitorsApi); 26 28 27 29 export { monitorsApi };
+17 -2
apps/server/src/v1/monitors/run/post.ts
··· 21 21 path: "/:id/run", 22 22 request: { 23 23 params: ParamsSchema, 24 + query: z 25 + .object({ 26 + "no-wait": z 27 + .boolean() 28 + .optional() 29 + .openapi({ 30 + description: "Don't wait for the result", 31 + }) 32 + .default(false), 33 + }) 34 + .openapi({}), 24 35 }, 25 36 responses: { 26 37 200: { ··· 35 46 }, 36 47 }); 37 48 38 - export function registerTriggerMonitor(api: typeof monitorsApi) { 49 + export function registerRunMonitor(api: typeof monitorsApi) { 39 50 return api.openapi(triggerMonitor, async (c) => { 40 51 const workspaceId = c.get("workspaceId"); 41 52 const { id } = c.req.valid("param"); 42 53 const limits = c.get("limits"); 43 - 54 + const { "no-wait": noWait } = c.req.valid("query"); 44 55 const lastMonth = new Date().setMonth(new Date().getMonth() - 1); 45 56 46 57 const count = ( ··· 171 182 body: JSON.stringify(payload), 172 183 }); 173 184 allResult.push(result); 185 + } 186 + 187 + if (noWait) { 188 + return c.json([], 200); 174 189 } 175 190 176 191 const result = await Promise.all(allResult);