mirror of
https://github.com/yangshun/tech-interview-handbook.git
synced 2025-07-31 14:12:37 +08:00
feat: scaffold monorepo
This commit is contained in:
27
apps/portal/src/utils/trpc.ts
Normal file
27
apps/portal/src/utils/trpc.ts
Normal file
@ -0,0 +1,27 @@
|
||||
// Src/utils/trpc.ts
|
||||
import { createReactQueryHooks } from '@trpc/react';
|
||||
import type { inferProcedureInput, inferProcedureOutput } from '@trpc/server';
|
||||
|
||||
import type { AppRouter } from '~/server/router';
|
||||
|
||||
export const trpc = createReactQueryHooks<AppRouter>();
|
||||
|
||||
/**
|
||||
* These are helper types to infer the input and output of query resolvers
|
||||
* @example type HelloOutput = inferQueryOutput<'hello'>
|
||||
*/
|
||||
export type inferQueryOutput<
|
||||
TRouteKey extends keyof AppRouter['_def']['queries'],
|
||||
> = inferProcedureOutput<AppRouter['_def']['queries'][TRouteKey]>;
|
||||
|
||||
export type inferQueryInput<
|
||||
TRouteKey extends keyof AppRouter['_def']['queries'],
|
||||
> = inferProcedureInput<AppRouter['_def']['queries'][TRouteKey]>;
|
||||
|
||||
export type inferMutationOutput<
|
||||
TRouteKey extends keyof AppRouter['_def']['mutations'],
|
||||
> = inferProcedureOutput<AppRouter['_def']['mutations'][TRouteKey]>;
|
||||
|
||||
export type inferMutationInput<
|
||||
TRouteKey extends keyof AppRouter['_def']['mutations'],
|
||||
> = inferProcedureInput<AppRouter['_def']['mutations'][TRouteKey]>;
|
Reference in New Issue
Block a user