mirror of
https://github.com/ArthurDanjou/trpc-nuxt.git
synced 2026-01-29 19:30:34 +01:00
refactor: use addAutoImport
This commit is contained in:
@@ -4,7 +4,7 @@ import { defu } from 'defu'
|
|||||||
// @ts-expect-error: No types
|
// @ts-expect-error: No types
|
||||||
import dedent from 'dedent'
|
import dedent from 'dedent'
|
||||||
|
|
||||||
import { addPlugin, addServerHandler, addTemplate, defineNuxtModule } from '@nuxt/kit'
|
import { addAutoImport, addPlugin, addServerHandler, addTemplate, defineNuxtModule } from '@nuxt/kit'
|
||||||
|
|
||||||
export interface ModuleOptions {
|
export interface ModuleOptions {
|
||||||
baseURL: string
|
baseURL: string
|
||||||
@@ -36,13 +36,11 @@ export default defineNuxtModule<ModuleOptions>({
|
|||||||
trpcURL: options.trpcURL,
|
trpcURL: options.trpcURL,
|
||||||
})
|
})
|
||||||
|
|
||||||
nuxt.hook('autoImports:extend', (imports) => {
|
addAutoImport([
|
||||||
imports.push(
|
{ name: 'useClient', from: join(runtimeDir, 'client') },
|
||||||
{ name: 'useClient', from: join(runtimeDir, 'client') },
|
{ name: 'useAsyncQuery', from: join(runtimeDir, 'client') },
|
||||||
{ name: 'useAsyncQuery', from: join(runtimeDir, 'client') },
|
{ name: 'useClientHeaders', from: join(runtimeDir, 'client') },
|
||||||
{ name: 'useClientHeaders', from: join(runtimeDir, 'client') },
|
])
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
addServerHandler({
|
addServerHandler({
|
||||||
route: `${finalConfig.trpcURL}/*`,
|
route: `${finalConfig.trpcURL}/*`,
|
||||||
|
|||||||
Reference in New Issue
Block a user