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.
2.1 kB ยท 85 lines
TypeScript
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586import { ListPrivateLocationsInput, createPrivateLocation, deletePrivateLocation, listPrivateLocations, updatePrivateLocation,} from "@openstatus/services/private-location";import { z } from "zod";
import { toServiceCtx, toTRPCError } from "../service-adapter";import { createTRPCRouter, protectedProcedure } from "../trpc";
export const privateLocationRouter = createTRPCRouter({ list: protectedProcedure .input(ListPrivateLocationsInput.optional()) .query(async ({ ctx, input }) => { try { const { items } = await listPrivateLocations({ ctx: toServiceCtx(ctx), input, }); return items; } catch (err) { toTRPCError(err); } }),
new: protectedProcedure .input( z.object({ name: z.string(), monitors: z.array(z.number()), token: z.string(), metadata: z.record(z.string(), z.string()).optional(), }), ) .mutation(async ({ ctx, input }) => { try { return await createPrivateLocation({ ctx: toServiceCtx(ctx), input: { name: input.name, token: input.token, monitors: input.monitors, metadata: input.metadata, }, }); } catch (err) { toTRPCError(err); } }),
update: protectedProcedure .input( z.object({ id: z.number(), name: z.string(), monitors: z.array(z.number()), metadata: z.record(z.string(), z.string()).optional(), }), ) .mutation(async ({ ctx, input }) => { try { return await updatePrivateLocation({ ctx: toServiceCtx(ctx), input, }); } catch (err) { toTRPCError(err); } }),
delete: protectedProcedure .input(z.object({ id: z.number() })) .mutation(async ({ ctx, input }) => { try { await deletePrivateLocation({ ctx: toServiceCtx(ctx), input, }); } catch (err) { toTRPCError(err); } }),});