Socket
Book a DemoInstallSign in
Socket

@musubi/core

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@musubi/core

Musubi 🪢 End-to-end typesafe communication. 🎉

latest
npmnpm
Version
0.14.0
Version published
Maintainers
1
Created
Source

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
}

FAQs

Package last updated on 12 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts