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

bot-web-interface

v2.0.14

Published

A lightweight ui to display information from node js. Structure can be controlled with a simple js object.

Downloads

19

Readme

bot-web-interface

This is a small project for displaying data of multiple sources on one webpage that gets automatically updated.

Basic Usage

bot-web-interface is a small tool to create a live-dashboard from data within node. It accomplishes this by running an express app in a http server, utilizing socket.io to send updates as they occur.

Startup

In order to start bot-web-interface you must first require it and initialize it.

const bwi = require("bot-web-interface");
//start up bwi
const bwi_instance = new bwi({
  //what port the http server should run on
  port: 2080,
  //what password the interface should have
  //null means no password is needed
  password: null
});

Data Schemas

bot-web-interface presents data through tiles, which are referred to as interfaces. Each Interface belongs to one block of data. In order to know how to render an interface you must specify a schema for it. A Schema is an array, specifying for each piece of data a name, a type, a label, as well as some optional options. A list of some possible types is given in this example:

bwi_instance.publisher.setDefaultStructure([
  {name: "greeting", type: "text", label: "Greeting"},
  {name: "balance", type: "progressBar", label: "Balance", options: {color: "green"}},
  {name: "imbalance", type: "progressBar", label: "Imbalance"},
  {name: "rating", type: "labelProgressBar", label: "Rating"}
]);

It is not necessary to specify a default structure if you specify the structure of each interface individually.

Interfaces

In order to display data you need to create interfaces. Interfaces are bound to the schema they use, as well as a data source, which supplies the data to be displayed.

//an interface using the default structure
const interface1 = bwi_instance.publisher.createInterface();
//specify a static data source
interface1.setDataSource(() => ({
  greeting:"Hello",
  //Take note that the progress needs to be supplied in %
  //and not as a range from 0 to 1
  balance:50,
  imbalance:31.4,
  rating:[60,"6/10"]
}));
//an interface using a custom structure
const interface2 = bwi_instance.publisher.createInterface([
  {name: "speech", type: "text", label: "See also"}
]);
//specify a dynamic data source
interface2.setDataSource(() => ({
  speech:"Hello "+["Cat","Dog","Cow","Monkey"][Math.floor(Math.random()*4)]
}));