(
run: (server: TestOrpcServer) => Promise<T>,
options: ServerOptions = {}
)
| 216 | type ServerOptions = Omit<Parameters<typeof createOrpcServer>[0], "host" | "port" | "context">; |
| 217 | |
| 218 | async function withTestOrpcServer<T>( |
| 219 | run: (server: TestOrpcServer) => Promise<T>, |
| 220 | options: ServerOptions = {} |
| 221 | ): Promise<T> { |
| 222 | const server = await createOrpcServer({ |
| 223 | host: "127.0.0.1", |
| 224 | port: 0, |
| 225 | // Tests in this file don't exercise context services unless explicitly supplied. |
| 226 | // eslint-disable-next-line @typescript-eslint/consistent-type-assertions |
| 227 | context: {} as ORPCContext, |
| 228 | ...options, |
| 229 | }); |
| 230 | |
| 231 | try { |
| 232 | return await run(server); |
| 233 | } finally { |
| 234 | await server.close(); |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | type OriginHeaders = Record<string, string> | ((server: TestOrpcServer) => Record<string, string>); |
| 239 |
no test coverage detected