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

things-js

v2.0.0

Published

Framework for building distribute IoT applications

Downloads

3

Readme

ThingsJS

ThingsJS is a framework for running JavaScript applications on IoT devices such as Raspberry PIs

  • NOTE: This repository is currently under active development and its contents are subject to breaking changes.

Directory Structure

/bin
/docs
/lib
    /core
    /util
/util
    /dashboard
    /gfs
/samples

This repository is organized thus:

  1. bin contains the things-js CLI (shell script) that is installed with the package. Also contains default config files.
  2. docs contains the API documentations generated by JSDoc.
  3. lib contains the core ThingsJS code
    1. core contains the main ThingsJS objects such as Code, CodeEngine, Pubsub, Dispatcher.
    2. util contains general-purpose utility modules used in the system.
  4. util contains supplementary apps and debug tools
    1. dashboard contains the ThingsJS Dashboard application; it is an express web-application
    2. gfs contains the ThingsJS distributed filesystem. The file server can be run as a standalone express web-application or as a express.Router object to be plugged into an existing application.
  5. samples contains raw JavaScript sample code (non-instrumented) that can be dispatched to ThingsJS workers.

Dependencies

  • The ThingsJS framework uses MQTT Pub/Sub as its main communication mechanism and assumes the existence of an active MQTT service. Either Mosquitto, or Mosca will do. ThingsJS provides a basic Mosca server that can be started with things-js pubsub command. The Pub/Sub service is referenced only by the URL (e.g. mqtt://localhost) within the ThingsJS framework and does not assume any specific implementation of the service.
~$ things-js pubsub
  • For running the Dashboard web-application, MongoDB is required as the Dashboard uses it to store the end-user code.
~$ service mongod start

Getting Started

For trying out the framework, you can follow the steps below:

Installation

Option 1

  1. git clone this repository
~$ git clone https://github.com/karthikp-ubc/ThingsJS.git
  1. npm install -g to install the package. (download all the npm dependencies and link the CLI tool) You may need to put sudo depending on your installation of NodeJS. You need the -g (global installation) option for using the CLI. If you don't plan on using the CLI, you can omit the -g option.
~$ cd ThingsJS
~/ThingsJS$ npm install -g

Option 2

  1. Install via npm
~$ sudo npm install -g things-js

You may omit the sudo depending on your NodeJS install settings.

Using the CLI

Along with the API provided, CLI is included for easy use. Commands available currently:

  • things-js dashboard
  • things-js worker {config}
  • things-js instrument {code}
  1. To start the Dashboard Application:
~$ things-js dash

#OR

~$ things-js dashboard

By default it connects to MQTT at localhost:1883, MongoDB at localhost:27017/things_dashboard, and listens on localhost:3000. To start the dashboard with a different configuration, you can use the -c or --config options with the config file path provided as an argument. e.g.

~$ things-js dash -c my_config.conf

This will start a web-application served at the specified port. You can watch the demo of the Dashboard here:

Click Image to see Demo Video

  1. Running a ThingsJS worker:

To start a ThingsJS worker, first you need to create a directory that will provide the NodeJS environment. This is because the worker needs to have a reference to the things-js module and any other npm modules that a ThingsJS user (developer) may require. If the worker cannot find a link to a node_modules directory, it will throw an error.

~$ mkdir hello_things
~$ cd hello_things
~$ npm link things-js

#create a config file for the worker first (e.g. node_00.conf) 

~/hello_things$ things-js worker node_00.conf

The configuration file is a required argument for starting the worker. It should contain the following information:

{
    "pubsub_url": "mqtt://localhost",
    "id": "node_00",
    "device": "raspberry-pi3"
}
  1. To instrument raw JavaScript code into a "ThingJS-compatible" code:
~$ things-js inst my_code.js

#OR

~$ things-js instrument my_code.js

By default the output file will have the same file name, with the extension .things.js. To specify the output file name, provide the optional argument with -o or --output. e.g.

~$ things-js inst my_code.js -o my_code.instrumented.js

License

MIT