@tim-code/browser-command

0.5.6 • Public • Published

browser-command

npm install @tim-code/browser-command

A companion library to gateway, this allows for backend endpoints to be called almost as if they were functions.

Philosophy

import * as command from "@tim-code/autotest"

// note this filename needs to correspond to backend cookie/endpoint (i.e. "fs")
// alternatively can just pass string instead of "import.meta.url"
// command.post("fs", "root")
command.post(import.meta.url, "root")
command.get(import.meta.url, "root")
command.request(import.meta.url, "root")
command.factory(import.meta.url)("root")

Typeical Usage

From web-service:

const run = command.factory(import.meta.url)

export function fetch(url, options = {}) {
  return run("fetch", { url, options })
}

Dependents (1)

Package Sidebar

Install

npm i @tim-code/browser-command

Weekly Downloads

9

Version

0.5.6

License

MIT

Unpacked Size

4.78 kB

Total Files

6

Last publish

Collaborators

  • timspro