refactor: 更好的orpc结构
This commit is contained in:
@@ -2,7 +2,7 @@ import { ORPCError, onError, ValidationError } from '@orpc/server'
|
||||
import { RPCHandler } from '@orpc/server/fetch'
|
||||
import { createFileRoute } from '@tanstack/react-router'
|
||||
import { z } from 'zod'
|
||||
import { router } from '@/api/routers'
|
||||
import { router } from '@/server/api/routers'
|
||||
|
||||
const handler = new RPCHandler(router, {
|
||||
interceptors: [
|
||||
@@ -49,7 +49,9 @@ export const Route = createFileRoute('/api/rpc/$')({
|
||||
ANY: async ({ request }) => {
|
||||
const { response } = await handler.handle(request, {
|
||||
prefix: '/api/rpc',
|
||||
context: {},
|
||||
context: {
|
||||
headers: request.headers,
|
||||
},
|
||||
})
|
||||
|
||||
return response ?? new Response('Not Found', { status: 404 })
|
||||
|
||||
@@ -4,7 +4,7 @@ import { isTauri } from '@tauri-apps/api/core'
|
||||
import { getCurrentWindow } from '@tauri-apps/api/window'
|
||||
import type { ChangeEventHandler, FormEventHandler } from 'react'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { orpc } from '@/lib/orpc/query-client'
|
||||
import { orpc } from '@/client/query-client'
|
||||
|
||||
export const Route = createFileRoute('/')({
|
||||
component: Todos,
|
||||
|
||||
Reference in New Issue
Block a user