systemRouter.ts 709 B

1234567891011121314151617181920212223242526272829
  1. import { z } from "zod";
  2. import { notifyOwner } from "./notification";
  3. import { adminProcedure, publicProcedure, router } from "./trpc";
  4. export const systemRouter = router({
  5. health: publicProcedure
  6. .input(
  7. z.object({
  8. timestamp: z.number().min(0, "timestamp cannot be negative"),
  9. })
  10. )
  11. .query(() => ({
  12. ok: true,
  13. })),
  14. notifyOwner: adminProcedure
  15. .input(
  16. z.object({
  17. title: z.string().min(1, "title is required"),
  18. content: z.string().min(1, "content is required"),
  19. })
  20. )
  21. .mutation(async ({ input }) => {
  22. const delivered = await notifyOwner(input);
  23. return {
  24. success: delivered,
  25. } as const;
  26. }),
  27. });