Socket
Socket
Sign inDemoInstall

@oada/client

Package Overview
Dependencies
Maintainers
8
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@oada/client

A lightweight client tool to interact with an OADA-compliant server


Version published
Weekly downloads
48
decreased by-61.9%
Maintainers
8
Weekly downloads
 
Created
Source

@oada/client

A lightweight client tool for interacting with an OADA-compliant server

npm

Installation

This module is available through npm. To install the module, simply run:

$ npm install @oada/client

Usage

Connect

const client = require("@oada/client")
const connection = await client.connect({
  domain: "api.oada.com", // domain of OADA server
  token: "abc" // token
})

GET

Single GET
const response = await connection.get({
  path: '/bookmarks/test',
  timeout: 1000  // timeout in milliseconds (optional)
})
Recursive GET
const dataTree = {
  "bookmarks": {
    "_type": "application/vnd.oada.bookmarks.1+json",
    "_rev": 0,
    "thing": {
      "_type": "application/json",
      "_rev": 0,
      "abc": {
        "*": {
          "_type": "application/json",
      	  "_rev": 0,
        }
      }
    }
  }
}
const response = await connection.get({
  path: '/bookmarks/thing',
  tree: dataTree,
  timeout: 1000  // timeout in milliseconds (optional)
})
Watch

A watch request can be issued by passing a callback function to watchCallback argument of a GET request.

const response = await connection.get({
  path: '/bookmarks/test',
  watchCallback: d => {
    console.log(d);
  },
  timeout: 1000  // timeout in milliseconds (optional)
})

Alternatively, one could explicitly send a watch request as follows.

const requestId = await connection.watch({
  path: '/bookmarks/test',
  rev: 1, // optional
  watchCallback: d => {
    console.log(d);
  },
  timeout: 1000  // timeout in milliseconds (optional)
})

To unwatch a resource, use the unwatch request.

const response = await connection.unwatch(requestId);

PUT

Single PUT
const response = await connection.put({
  path: "/bookmarks/test",
  data: { thing: "abc" },
  contentType: "application/json",
  timeout: 1000  // timeout in milliseconds (optional)
})
Tree PUT
const dataTree = {
  "bookmarks": {
    "_type": "application/vnd.oada.bookmarks.1+json",
    "_rev": 0,
    "thing": {
      "_type": "application/json",
      "_rev": 0,
      "abc": {
        "*": {
          "_type": "application/json",
      	  "_rev": 0,
        }
      }
    }
  }
}
const response = await connection.put({
  path: '/bookmarks/thing/abc/xyz/zzz',
  tree: dataTree,
  data: { test: "something" },
  timeout: 1000  // timeout in milliseconds (optional)
})

HEAD

const response = await connection.head({
  path: '/bookmarks/test',
  timeout: 1000  // timeout in milliseconds (optional)
})

FAQs

Package last updated on 16 Mar 2021

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc