Skip to content

Commit

Permalink
goldilocks abstraction? :(
Browse files Browse the repository at this point in the history
  • Loading branch information
mmkal committed Aug 21, 2024
1 parent 2a97e59 commit 8fa6f59
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,20 @@ export {
initTRPC,
} from '@trpc/server'

/** "starter" trpc instance. Useful to get a new project started without needing to set up `@trpc/server` manually */
/**
* A "starter" trpc instance. Useful to get a new project started without needing to set up `@trpc/server` manually.
* Equivalent to `initTRPC.meta<TrpcCliMeta>().create()`.
* Note: if you need to specify a context, use {@linkcode createTrpc}.
*/
export const trpc = initTRPC.meta<TrpcCliMeta>().create()

/**
* Create a "starter" trpc instance, with context.
* Equivalent to `initTRPC.meta<TrpcCliMeta>().context<Context>()`.
* Note: if you don't need to specify a context, just use {@linkcode trpc}.
*/
export const createTrpc = <Context extends {}>() => initTRPC.meta<TrpcCliMeta>().context<Context>().create()

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type AnyRouter = Router<any>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down

0 comments on commit 8fa6f59

Please sign in to comment.