mirror of
https://github.com/ArthurDanjou/trpc-nuxt.git
synced 2026-01-20 06:51:44 +01:00
update readme
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { dirname, join, resolve } from 'pathe'
|
||||
import { dirname, join } from 'pathe'
|
||||
import { addServerHandler, defineNuxtModule } from '@nuxt/kit'
|
||||
import fs from 'fs-extra'
|
||||
|
||||
@@ -31,9 +31,6 @@ export default defineNuxtModule<ModuleOptions>({
|
||||
)
|
||||
})
|
||||
|
||||
const srcDir = nuxt.options.srcDir
|
||||
const optionsPath = resolve(srcDir, 'server/fn/index.ts')
|
||||
|
||||
await fs.ensureDir(dirname(clientPath))
|
||||
|
||||
await fs.writeFile(clientPath, `
|
||||
@@ -61,24 +58,12 @@ export default defineNuxtModule<ModuleOptions>({
|
||||
await fs.writeFile(handlerPath, `
|
||||
import { createTRPCHandler } from 'trpc-nuxt/api'
|
||||
import * as functions from '~/server/fn'
|
||||
|
||||
export default createTRPCHandler({
|
||||
router: functions.router
|
||||
router: functions.router,
|
||||
createContext: functions.createContext ?? undefined,
|
||||
responseMeta: functions.responseMeta ?? undefined,
|
||||
})
|
||||
`)
|
||||
|
||||
if (!fs.existsSync(optionsPath)) {
|
||||
await fs.writeFile(optionsPath, `
|
||||
// Generated by trpc-nuxt
|
||||
import * as trpc from '@trpc/server'
|
||||
|
||||
export const router = trpc
|
||||
.router()
|
||||
.query('hello', {
|
||||
resolve: () => 'world',
|
||||
});
|
||||
|
||||
export type Router = typeof router
|
||||
`.trimStart())
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user