npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-visionect

v0.0.8

Published

Thin nodejs client for the Visionect Server Management API

Downloads

19

Readme

node-visionect CI

A thin node.js Promise based wrapper around the Visionect Server Management API

Installation NPM Package Version

npm add node-visionect

Example

const VisionectApiClient = require('node-joan')

const vss = new VisionectApiClient({
  apiServer: 'https://localhost:8081',
  apiKey: '<apiKey>',
  apiSecret: '<apiSecret>'
})

vss.devices.get()
  .then(res => console.log(res.status, res.headers, res.data))
  .catch(err => console.error(err))

// Update URL
vss.sessions.patch(uuid, {Backend: {Fields: {url: 'https://example.com'}}})

This library is used in production by the Newswall project - feel free to refer to it for further usage examples.

APIs

Devices APIs

vss.devices.get() // get all devices
vss.devices.get(uuid) // get a particular device
vss.devices.get(uuid, from, to = now, group = false) // Get an array of historical statuses; See http://api.vss.com/#device-status-device-status

vss.devices.update(uuid, data) // update a particular device
vss.devices.update(data) // update all devices
vss.devices.patch(uuid, data) // Partial update a device

vss.devices.delete(uuid) // delete a devices

vss.devices.reboot(uuid1, uuid2, /*...*/) // reboot devices

Device Config APIs

vss.devices.config.get(uuid) // Get all config for device
vss.devices.config.get(uuid, [typeId1, typeId2]/*, ...*/) // Get particular configs e.g. vss.devices.config.get(uuid, [65, 67]) to get WiFi info

vss.devices.config.set(uuid, {Type: id1, value: v1}, {Type: id1, value: v2}, /*...*/) // Set configs

// Full list of type ids: https://docs.visionect.com/AppDevelopment/generalJsExtensions.html#tclv-list
// e.g. to disable system screens (the ones that show when charging or no WiFi)
vss.devices.config.set(uuid, {Type: 49, Value: '0'})

Live View APIs

vss.view.device(uuid) // return current image that is displayed on the device
vss.view.server(uuid) // return the server side image for the device
vss.view.set(uuid, img) // Set the image on device; see http://api.vss.com/#backends

//Example: Save the live view image locally
const fs = require('fs')
const fileType = '.png'
vss.view.device(uuid, fileType).then(res => fs.writeFileSync(uuid + fileType, res.data))

Session APIs

vss.sessions.get() // get all sessions
vss.sessions.get(uuid) // get a particular session

vss.sessions.update(uuid, data) // update a particular session
vss.sessions.update(data) // update all sessions
vss.sessions.patch(uuid, data) // Partial update a session

vss.sessions.create(data) // create a session

vss.sessions.restart(uuid1, uuid2, /*...*/) // restart sessions
vss.sessions.clearCache(uuid1, uuid2, /*...*/) // clear session caches

User APIs

vss.users.get() // get all users
vss.users.get(username) // get a particular user

vss.users.update(username, data) // update a particular user
vss.users.update(data) // update all users
vss.users.patch(uuid, data) // Partial update a user

vss.users.create(data) // create a user

Server APIs

vss.server.status() // Get server status
vss.server.config() // Get server config
vss.server.config(data) // Set server config
vss.server.config(data, patch = true) // Partial update server config
vss.server.orphans(all = true) // See http://api.vss.com/#health

Primitive APIs

Directly call any HTTP endpoints using the following low level utils:

vss.http.get(path)
vss.http.post(path, data)
vss.http.put(path, data)
vss.http.patch(path, data)
vss.http.delete(path, data)
vss.http.options(path)

Plugins

You can access the underlying axios HTTP caller via vss.http. This makes it possible to use any axios plugins e.g.

// This will print all API calls as curl commands to console
const curlirize = require('axios-curlirize')
curlirize(vss.http)

Intercept Requests / Responses

Use axios interceptors to intercept requests/response:

// Intercept requests e.g. to block certain calls
vss.http.interceptors.request.use(req => {
  return (process.env.NODE_ENV === 'test' && req.method.toUpperCase() !== 'GET') ?
    Promise.reject(`Cannot make ${req.method} API calls from tests`) : req
})

// Intercept responses e.g. to log the response / request
vss.http.interceptors.response.use(
  res => {
    console.log(res.request.method, res.request.path, res.status, res.headers)
    return res
  },
  err => {
    console.error('Received non-2xx response', err)
    return Promise.reject(err)
  }
)

// 3rd party logger: https://github.com/hg-pyun/axios-logger
vss.http.interceptors.request.use(AxiosLogger.requestLogger)