26 lines
686 B
TypeScript
26 lines
686 B
TypeScript
import { publicProcedure, router } from '~/server/trpc/init';
|
|
import { z } from 'zod';
|
|
import { getContact, getContacts } from "~/server/utils/data";
|
|
|
|
export const appRouter = router({
|
|
hello: publicProcedure.input(
|
|
z.object({
|
|
text: z.string(),
|
|
}),
|
|
).query((opts) => {
|
|
return {
|
|
greeting: `hello ${opts.input.text}`,
|
|
};
|
|
}),
|
|
contactList: publicProcedure.query(async () => {
|
|
return await getContacts();
|
|
}),
|
|
contactGet: publicProcedure.input(
|
|
z.object({ contactId: z.string() })
|
|
).query(async (opts) => {
|
|
return await getContact(opts.input.contactId);
|
|
}),
|
|
});
|
|
|
|
// export type definition of API
|
|
export type AppRouter = typeof appRouter; |