Skip to content

Commit 551fe2c

Browse files
committed
feat(api): use oRPC's new Response Validation Plugin (v1.8.6)
Resources: - https://github.com/unnoq/orpc/releases/tag/v1.8.6 - https://orpc.unnoq.com/docs/plugins/response-validation
1 parent bf578ee commit 551fe2c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/api/src/client/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { createORPCClient } from '@orpc/client';
2+
import { ResponseValidationPlugin } from '@orpc/contract/plugins';
23
import { OpenAPILink } from '@orpc/openapi-client/fetch';
34
import { createTanstackQueryUtils } from '@orpc/tanstack-query';
45
import urlJoin from 'url-join';
56
import type {
67
ContractRouterClient,
78
InferContractRouterOutputs,
89
} from '@orpc/contract';
9-
import type { JsonifiedClient } from '@orpc/openapi-client';
1010
import { appContract } from '../contracts';
1111

1212
export { isDefinedError, safe } from '@orpc/client';
@@ -24,14 +24,15 @@ export type RouterOutput = InferContractRouterOutputs<typeof appContract>;
2424
export const createAPIClient = ({ serverUrl, apiPath }: APIClientOptions) => {
2525
const link = new OpenAPILink(appContract, {
2626
url: urlJoin(serverUrl, apiPath),
27+
plugins: [new ResponseValidationPlugin(appContract)],
2728
fetch: (request, init) => {
2829
return globalThis.fetch(request, {
2930
...init,
3031
credentials: 'include',
3132
});
3233
},
3334
});
34-
const client: JsonifiedClient<ContractRouterClient<typeof appContract>> =
35+
const client: ContractRouterClient<typeof appContract> =
3536
createORPCClient(link);
3637

3738
return client;

0 commit comments

Comments
 (0)