-
-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathserver.ts
More file actions
18 lines (16 loc) · 611 Bytes
/
server.ts
File metadata and controls
18 lines (16 loc) · 611 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import type { BirpcGroup, EventOptions } from 'birpc'
import { createBirpcGroup } from 'birpc'
export function createRpcServer<
ClientFunctions extends object = Record<string, never>,
ServerFunctions extends object = Record<string, never>,
>(
functions: ServerFunctions,
options: {
preset: (rpc: BirpcGroup<ClientFunctions, ServerFunctions>) => void
rpcOptions?: EventOptions<ClientFunctions>
},
): BirpcGroup<ClientFunctions, ServerFunctions> {
const rpc = createBirpcGroup<ClientFunctions, ServerFunctions>(functions, [], options?.rpcOptions ?? {})
options?.preset(rpc)
return rpc
}