@musubi/core

0.14.0Β β€’Β PublicΒ β€’Β Published

Musubi πŸͺ’

End-to-end typesafe communication. πŸŽ‰

@musubi/core

Documentation

Full documentation for @musubi/core can be found here.

Installation

# npm
npm install @musubi/core

# Yarn
yarn add @musubi/core

Usage

import { defineSchema, CommunicatorClient } from "@musubi/core";
import { createHttpClientLink } from "@musubi/http-link";
import { z } from "zod";

const schema = defineSchema({
  queries: {
    greet: query()
      .withPayload(
        z.object({
          name: z.string()
        })
      )
      .withResult(z.string())
  }
});

async function main() {
  const httpLink = createHttpClientLink({
    url: "http://localhost:3000/api"
  });
  const client = new CommunicatorClient(schema, [httpLink]);

  // Querying the greeting
  const response = await client.query("greet", {
    name: "John"
  });

  console.log("response", response); // Hello John
}

Dependencies (2)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i @musubi/core

    Weekly Downloads

    1

    Version

    0.14.0

    License

    MIT

    Unpacked Size

    106 kB

    Total Files

    6

    Last publish

    Collaborators

    • theunderscorer