MCPcopy
hub / github.com/ts-rest/ts-rest / initContract

Function initContract

libs/ts-rest/core/src/lib/dsl.ts:338–361  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

336 * @returns {ContractInstance}
337 */
338export const initContract = (): ContractInstance => {
339 return {
340 // @ts-expect-error - this is a type error, but it's not clear how to fix it
341 router: (endpoints, options) => recursivelyApplyOptions(endpoints, options),
342 query: (args) => args,
343 mutation: (args) => args,
344 responses: (args) => args,
345 response: () => ContractPlainTypeRuntimeSymbol,
346 body: () => ContractPlainTypeRuntimeSymbol,
347 type: () => ContractPlainTypeRuntimeSymbol,
348 otherResponse: <T extends ContractAnyType>({
349 contentType,
350 body,
351 }: {
352 contentType: string;
353 body: T;
354 }) =>
355 ({
356 contentType,
357 body,
358 }) as ContractOtherResponse<T>,
359 noBody: () => ContractNoBody,
360 };
361};

Calls 1

recursivelyApplyOptionsFunction · 0.85

Tested by

no test coverage detected