Open History to see the last commit
1import { TSS_SERVER_FUNCTION } from '@tanstack/start-client-core'
2import { getServerFnById } from './getServerFnById'
3import type { ClientFnMeta } from '@tanstack/start-client-core'
4β
5export const createSsrRpc = (functionId: string) => {
6 const url = process.env.TSS_SERVER_FN_BASE + functionId
7 const serverFnMeta: ClientFnMeta = { id: functionId }
8β
9 const fn = async (...args: Array<any>): Promise<any> => {
10 const serverFn = await getServerFnById(functionId, { origin: 'server' })
11 return serverFn(...args)
12 }
13β
14 return Object.assign(fn, {
15 url,
16 serverFnMeta,
17 [TSS_SERVER_FUNCTION]: true,
18 })
19}