mirror of
https://github.com/ArthurDanjou/trpc-nuxt.git
synced 2026-01-14 12:14:40 +01:00
update docs
This commit is contained in:
@@ -35,7 +35,7 @@ Initialize your tRPC backend using the `initTRPC` function and create your first
|
|||||||
::code-group
|
::code-group
|
||||||
|
|
||||||
```ts [server/trpc/trpc.ts]
|
```ts [server/trpc/trpc.ts]
|
||||||
import { TRPCError, initTRPC } from '@trpc/server'
|
import { initTRPC } from '@trpc/server'
|
||||||
|
|
||||||
// Avoid exporting the entire t-object since it's not very
|
// Avoid exporting the entire t-object since it's not very
|
||||||
// descriptive and can be confusing to newcomers used to t
|
// descriptive and can be confusing to newcomers used to t
|
||||||
@@ -49,7 +49,7 @@ export const publicProcedure = t.procedure
|
|||||||
|
|
||||||
```ts [server/trpc/routers/index.ts]
|
```ts [server/trpc/routers/index.ts]
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
import { publicProcedure, router } from '..'
|
import { publicProcedure, router } from '../trpc'
|
||||||
|
|
||||||
export const appRouter = router({
|
export const appRouter = router({
|
||||||
hello: publicProcedure
|
hello: publicProcedure
|
||||||
@@ -71,7 +71,7 @@ export type AppRouter = typeof appRouter
|
|||||||
|
|
||||||
```ts [server/api/trpc/[trpc].ts]
|
```ts [server/api/trpc/[trpc].ts]
|
||||||
import { createNuxtApiHandler } from 'trpc-nuxt'
|
import { createNuxtApiHandler } from 'trpc-nuxt'
|
||||||
import { appRouter } from '../../trpc/routers'
|
import { appRouter } from '@/server/trpc/routers'
|
||||||
|
|
||||||
// export API handler
|
// export API handler
|
||||||
export default createNuxtApiHandler({
|
export default createNuxtApiHandler({
|
||||||
@@ -93,7 +93,7 @@ Create a set of strongly-typed composables using your API's type signature.
|
|||||||
```ts [plugins/client.ts]
|
```ts [plugins/client.ts]
|
||||||
import { httpBatchLink } from '@trpc/client'
|
import { httpBatchLink } from '@trpc/client'
|
||||||
import { createTRPCNuxtProxyClient } from 'trpc-nuxt/client'
|
import { createTRPCNuxtProxyClient } from 'trpc-nuxt/client'
|
||||||
import type { AppRouter } from '~~/server/trpc/routers'
|
import type { AppRouter } from '@/server/trpc/routers'
|
||||||
|
|
||||||
export default defineNuxtPlugin(() => {
|
export default defineNuxtPlugin(() => {
|
||||||
const client = createTRPCNuxtProxyClient<AppRouter>({
|
const client = createTRPCNuxtProxyClient<AppRouter>({
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { createNuxtApiHandler } from 'trpc-nuxt'
|
import { createNuxtApiHandler } from 'trpc-nuxt'
|
||||||
import { appRouter } from '../../trpc/routers'
|
import { appRouter } from '@/server/trpc/routers'
|
||||||
import { createContext } from '~~/server/trpc/context'
|
import { createContext } from '@/server/trpc/context'
|
||||||
|
|
||||||
export default createNuxtApiHandler({
|
export default createNuxtApiHandler({
|
||||||
router: appRouter,
|
router: appRouter,
|
||||||
|
|||||||
Reference in New Issue
Block a user