mirror of
https://github.com/ArthurDanjou/trpc-nuxt.git
synced 2026-02-02 05:08:01 +01:00
look for functions in server/trpc/index
This commit is contained in:
@@ -21,7 +21,7 @@ export default defineNuxtConfig({
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Create your tRPC [routes](https://trpc.io/docs/router) and [context](https://trpc.io/docs/context) under `~/trpc/index.ts`:
|
Create your tRPC [routes](https://trpc.io/docs/router) and [context](https://trpc.io/docs/context) under `~/server/trpc/index.ts`:
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
// ~/trpc/index.ts
|
// ~/trpc/index.ts
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ export default defineNuxtModule<ModuleOptions>({
|
|||||||
|
|
||||||
await fs.writeFile(clientPath, `
|
await fs.writeFile(clientPath, `
|
||||||
import * as trpc from '@trpc/client'
|
import * as trpc from '@trpc/client'
|
||||||
import type { router } from '~/trpc'
|
import type { router } from '~/server/trpc'
|
||||||
|
|
||||||
const client = trpc.createTRPCClient<typeof router>({
|
const client = trpc.createTRPCClient<typeof router>({
|
||||||
url: process.browser ? '/trpc' : 'http://localhost:3000/trpc',
|
url: process.browser ? '/trpc' : 'http://localhost:3000/trpc',
|
||||||
@@ -45,7 +45,7 @@ export default defineNuxtModule<ModuleOptions>({
|
|||||||
|
|
||||||
await fs.writeFile(handlerPath, `
|
await fs.writeFile(handlerPath, `
|
||||||
import { createTRPCHandler } from 'trpc-nuxt/api'
|
import { createTRPCHandler } from 'trpc-nuxt/api'
|
||||||
import * as functions from '~/trpc'
|
import * as functions from '~/server/trpc'
|
||||||
|
|
||||||
export default createTRPCHandler({
|
export default createTRPCHandler({
|
||||||
router: functions.router,
|
router: functions.router,
|
||||||
|
|||||||
Reference in New Issue
Block a user