830c908712
- orpc.ts: 改为纯 createTanstackQueryUtils,不再依赖 experimental_ API - 抽出 src/client/queries/todo.ts 的 useInvalidateTodos,避免 query key 散落页面 - shutdown: setTimeout 内 db.$client.end() 失败也走 process.exit - 删除 db/index.ts 未被使用的 DB 类型导出 - 删除 env.ts 未被消费的 VITE_APP_TITLE,根 title 改为 package.json name - 清理 routes/index.tsx 的 JSX 区段注释、compose.yaml 注释掉的端口块、robots.txt URL 注释
28 lines
866 B
TypeScript
28 lines
866 B
TypeScript
import { createORPCClient } from '@orpc/client'
|
|
import { RPCLink } from '@orpc/client/fetch'
|
|
import { createRouterClient } from '@orpc/server'
|
|
import { createTanstackQueryUtils } from '@orpc/tanstack-query'
|
|
import { createIsomorphicFn } from '@tanstack/react-start'
|
|
import { getRequestHeaders } from '@tanstack/react-start/server'
|
|
import { router } from '@/server/api/routers'
|
|
import type { RouterClient } from '@/server/api/types'
|
|
|
|
const getORPCClient = createIsomorphicFn()
|
|
.server(() =>
|
|
createRouterClient(router, {
|
|
context: () => ({
|
|
headers: getRequestHeaders(),
|
|
}),
|
|
}),
|
|
)
|
|
.client(() => {
|
|
const link = new RPCLink({
|
|
url: `${window.location.origin}/api/rpc`,
|
|
})
|
|
return createORPCClient<RouterClient>(link)
|
|
})
|
|
|
|
const client: RouterClient = getORPCClient()
|
|
|
|
export const orpc = createTanstackQueryUtils(client)
|