Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/openstatusHQ/openstatus. ๐ซ Status page with uptime monitoring & API monitoring as code ๐ซ openstatus.dev
bun drizzle-orm monitoring monitoring-as-code nextjs observability on-call open-source shadcn-ui status-page statuspage synthetic-monitoring tinybird turso uptime uptime-checker uptime-monitor
Something went wrong. Try again.
1.1 kB ยท 40 lines
TypeScript
1234567891011121314151617181920212223242526272829303132333435363738394041import { z } from "zod";
import type { Assertion } from "./types";import { DnsRecordAssertion, HeaderAssertion, JsonBodyAssertion, StatusAssertion, TextBodyAssertion, base, headerAssertion, jsonBodyAssertion, recordAssertion, statusAssertion, textBodyAssertion,} from "./v1";
export function serialize(assertions: Assertion[]): string { return JSON.stringify(assertions.map((a) => a.schema));}export function deserialize(s: string): Assertion[] { const bases = z.array(base).parse(JSON.parse(s)); return bases.map((b) => { switch (b.type) { case "status": return new StatusAssertion(statusAssertion.parse(b)); case "header": return new HeaderAssertion(headerAssertion.parse(b)); case "jsonBody": return new JsonBodyAssertion(jsonBodyAssertion.parse(b)); case "textBody": return new TextBodyAssertion(textBodyAssertion.parse(b)); case "dnsRecord": return new DnsRecordAssertion(recordAssertion.parse(b));
default: throw new Error(`unknown assertion type: ${b.type}`); } });}