Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | 6x 4x 4x 1x 3x | import { TRPCError } from "@trpc/server";
import { z } from "zod";
import { wait } from "~utils/promise";
import { unauthProcedure } from "~web/handlers/trpc";
export const procedure = unauthProcedure
.meta({
title: "Ping",
description:
"Test endpoint that waits a given timeout and echoes back a pong, optionally throwing an error.",
})
.input(
z.object({
timeout: z.number(),
error: z.boolean().optional(),
}),
)
.query(async ({ input: { timeout, error } }) => {
await wait(timeout);
if (error) {
throw new TRPCError({
code: "BAD_REQUEST",
message: "This is bad!",
});
}
return { message: "PONG" as const };
});
|