hyper-connect
    TypeScript icon, indicating that this package has built-in type declarations

    0.1.10 • Public • Published

    ⚡️ hyper-connect ⚡️

    hyper-connect is a client for [hyper](https://docs.hyper.io) - the client leverages the `Request` object from the fetch specification to construct a http request to send to the hyper server. The hyper-connect library handles all of the redundant details of a fetch request, so you can just specify the unique differences of your request.

    Nest Badge Test


    Table of Contents


    Install

    NodeJS

    npm install hyper-connect

    Getting Started

    NodeJS (TypeScript)

    import { connect } from "hyper-connect";
    
    const hyper = connect(process.env.HYPER as string);
    
    await hyper.data.add({ id: "game-1", type: "game", name: "Donkey Kong" });
    await hyper.data.add({ id: "game-2", type: "game", name: "Pac Man" });
    await hyper.data.add({ id: "game-3", type: "game", name: "Galaga" });
    
    const results = await hyper.data.query({ type: "game" });

    NodeJS (ESM)

    import { connect } from "hyper-connect";
    
    const hyper = connect(process.env.HYPER);
    
    await hyper.data.add({ id: "game-1", type: "game", name: "Donkey Kong" });
    await hyper.data.add({ id: "game-2", type: "game", name: "Pac Man" });
    await hyper.data.add({ id: "game-3", type: "game", name: "Galaga" });
    
    const results = await hyper.data.query({ type: "game" });

    NodeJS (CJS)

    const { connect } = require("hyper-connect");
    
    const hyper = connect(process.env.HYPER);
    
    await hyper.data.add({ id: "game-1", type: "game", name: "Donkey Kong" });
    await hyper.data.add({ id: "game-2", type: "game", name: "Pac Man" });
    await hyper.data.add({ id: "game-3", type: "game", name: "Galaga" });
    
    const results = await hyper.data.query({ type: "game" });

    Deno

    import { connect } from "https://x.nest.land/hyper-connect@VERSION/deno/mod.ts";
    
    const HYPER = Deno.env.get("HYPER"); // connect string: cloud://key:secret@cloud.hyper.io/:app
    
    const hyper = connect(HYPER)();
    
    await hyper.data.add({ id: "game-1", type: "game", name: "Donkey Kong" });
    await hyper.data.add({ id: "game-2", type: "game", name: "Pac Man" });
    await hyper.data.add({ id: "game-3", type: "game", name: "Galaga" });
    
    const results = await hyper.data.query({ type: "game" });

    With hyper-connect, you can access all of the hyper services. hyper-connect uses the fetch library to execute REST requests for you.

    Examples

    How to add a document to hyper data?

    const doc = {
      id: "movie-1",
      type: "movie",
      title: "Dune",
      year: "2021",
    };
    
    const result = await hyper.data.add(doc);
    console.log(result); // {ok: true, id: "movie-1"}

    How to get all the documents of type 'movie'?

    const result = await hyper.data.query({ type: "movie" });
    console.log(result); // {ok: true, docs: [...]}

    How to add a cache key/value pair to hyper cache?

    const result = await hyper.cache.add("key", { counter: 1 });
    console.log(result); // {ok: true}

    Documentation

    hyper is a suite of service apis, with hyper connect you can specify the api you want to connect with and the action you want to perform. hyper.[service].[action] - with each service there are a different set of actions to call. This table breaks down the service and action with description of the action.

    data

    Service Action Description
    data add creates a json document in the hyper data store
    data list lists the documents given a start,stop,limit range
    data get retrieves a document by id
    data update updates a given document by id
    data remove removes a document from the store
    data query queries the store for a set of documents based on selector criteria
    data index creates an index for the data store
    data bulk inserts, updates, and removed document via a batch of documents

    cache

    Service Action Description
    cache add creates a json document in the hyper cache store with a key
    cache get retrieves a document by key
    cache set sets a given document by key
    cache remove removes a document from the cache
    cache query queries the cache for a set of documents based on a pattern matcher

    search

    Service Action Description
    search add indexes a json document in the hyper search index
    search get retrieves a document from index
    search remove removes a document from the index
    search query searches index by text
    search load loads a batch of documents

    Contributing


    License

    Apache 2.0

    Keywords

    none

    Install

    npm i hyper-connect

    DownloadsWeekly Downloads

    218

    Version

    0.1.10

    License

    MIT

    Unpacked Size

    199 kB

    Total Files

    67

    Last publish

    Collaborators

    • hyper63