kkrpc
    Preparing search index...

    Function defineAPI

    • Define a complete API with schema-first validation. Identity function — returns the object as-is but enables InferAPI<typeof api>.

      Type Parameters

      • T extends Record<string, unknown>

      Parameters

      • api: T

      Returns T

      const api = defineAPI({
      echo: defineMethod({ input: z.tuple([z.string()]), output: z.string() }, async (msg) => msg),
      math: {
      add: defineMethod({ input: z.tuple([z.number(), z.number()]), output: z.number() }, async (a, b) => a + b),
      }
      })