Open-source status page, incident response and uptime monitoring
TypeScript alertingincident-managementmcpmcp-servermonitoringmonitoring-as-codeobservabilityon-callopen-sourcesrestatus-pagestatuspagesynthetic-monitoringterraformtinybirdtursouptimeuptime-checkeruptime-monitor
🐛 partial monitor (#1288)
Thibault Le Ouay86a17b391358
diff --git a/apps/server/src/routes/v1/monitors/put.test.ts b/apps/server/src/routes/v1/monitors/put.test.tsindex 71b951002..df274a946 100644--- a/apps/server/src/routes/v1/monitors/put.test.ts+++ b/apps/server/src/routes/v1/monitors/put.test.ts@@ -1,9 +1,8 @@import { expect, test } from "bun:test";import { app } from "@/index";-import { MonitorSchema } from "./schema";-test("update the monitor", async () => {+test("Partial update the monitor", async () => {const res = await app.request("/v1/monitor/1", {method: "PUT",headers: {@@ -15,11 +14,7 @@ test("update the monitor", async () => {}),});- const result = MonitorSchema.safeParse(await res.json());-- expect(res.status).toBe(200);- expect(result.success).toBe(true);- expect(result.data?.name).toBe("New Name");+ expect(res.status).toBe(400);});test("invalid monitor id should return 404", async () => {diff --git a/apps/server/src/routes/v1/monitors/put.ts b/apps/server/src/routes/v1/monitors/put.tsindex ce575f9c0..0c0fe1679 100644--- a/apps/server/src/routes/v1/monitors/put.ts+++ b/apps/server/src/routes/v1/monitors/put.ts@@ -28,7 +28,7 @@ const putRoute = createRoute({description: "The monitor to update",content: {"application/json": {- schema: HTTPMonitorSchema.partial().or(TCPMonitorSchema.partial()),+ schema: HTTPMonitorSchema.or(TCPMonitorSchema),},},},@@ -91,7 +91,7 @@ export function registerPutMonitor(api: typeof monitorsApi) {}if (_monitor.jobType === "http") {- const data = HTTPMonitorSchema.partial().parse(input);+ const data = HTTPMonitorSchema.parse(input);const { request, regions, assertions, otelHeaders, ...rest } = data;const headers = data?.request?.headers@@ -114,15 +114,12 @@ export function registerPutMonitor(api: typeof monitorsApi) {.update(monitor).set({...rest,- regions: regions ? regions.join(",") : _monitor.regions,- headers: headersEntries- ? JSON.stringify(headersEntries)- : _monitor.headers,+ regions: regions.join(","),+ headers: headersEntries ? JSON.stringify(headersEntries) : undefined,otelHeaders: otelHeadersEntries? JSON.stringify(otelHeadersEntries)- : _monitor.otelHeaders,- assertions:- assert.length > 0 ? serialize(assert) : _monitor.assertions,+ : undefined,+ assertions: assert.length > 0 ? serialize(assert) : undefined,timeout: input.timeout || 45000,updatedAt: new Date(),})@@ -133,7 +130,7 @@ export function registerPutMonitor(api: typeof monitorsApi) {return c.json(r, 200);}if (_monitor.jobType === "tcp") {- const data = TCPMonitorSchema.partial().parse(input);+ const data = TCPMonitorSchema.parse(input);const { request, regions, otelHeaders, ...rest } = data;const otelHeadersEntries = otelHeaders@@ -147,10 +144,10 @@ export function registerPutMonitor(api: typeof monitorsApi) {.update(monitor).set({...rest,- regions: regions ? regions.join(",") : _monitor.regions,+ regions: regions.join(","),otelHeaders: otelHeadersEntries? JSON.stringify(otelHeadersEntries)- : _monitor.otelHeaders,+ : undefined,timeout: input.timeout || 45000,updatedAt: new Date(),})