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

evrythng-cli-plugin-reactor-test

v1.0.0

Published

Plugin for the EVRYTHNG CLI that allows testing of a Reactor script.

Downloads

1

Readme

evrythng-cli-plugin-reactor-test

Plugin for the EVRYTHNG CLI allowing local testing of Reactor scripts before uploading them to the Platform. This allows easier debugging and faster iterative development.

Installation

Simply install alongside the CLI to make the reactor-test command set available to use. Typically this is a global installation:

$ npm i -g evrythng-cli-plugin-reactor-test

Configuration

First, use the create-config command to create a reactor-config.json file, which is used to set the simulated event parameters (i.e: the action that was created, or the Thng property update that occurred):

$ evrythng reactor-test create-config

The parameters are as follows:

  • apiUrl - The main EVRYTHNG API URL.

  • function - The Reactor event handler function to simulate.

  • event - Object describing the event parameter passed to a Reactor script when it runs. See the appropriate event type to see what this should look like.

  • realistic - Set to false to print logs as they occur, and be notified of uncaught exceptions and Promise rejections. Useful for debugging errors preventing done() from being called.

An example reactor-config.json for onActionCreated is shown below:

{
  "apiUrl": "https://api.evrythng.com",
  "function": "onActionCreated",
  "event": {
    "action": {
      "id": "Uq24ycCsHc6pwHaaaGgEVCqf",
      "createdAt": 1552556638090,
      "customFields": {
        "serials": ["16746837648", "16746837649", "16746837650"]
      },
      "timestamp": 1552556638090,
      "type": "scans",
      "user": "UqfRhpwNc5d2EHaaw3CCdwre",
      "location": {
        "place": "UqfwY2FfBbtHErRwRmEP6aMk",
        "latitude": 42.856556,
        "longitude": 13.766146,
        "position": {
          "type": "Point",
          "coordinates": [
            13.766146,
            42.856556
          ]
        }
      },
      "locationSource": "place",
      "createdByProject": "UqAdfnmQ5Hp8HAaaRmdaRxrp",
      "createdByApp": "U6Cwh3eAmDxecFRww4ycVt3c",
      "collection": "UMk4xq2XpQfbwdawRGD7gb4m"
    }
  },
  "realistic": false
}

Usage

Once reactor-config.json is set up with the simulation parameters, specify the relative paths to the script and the config file along with the appropriate Trusted Application API Key to run the script locally:

$ evrythng reactor-test run $script $config --api-key $trustedAppApiKey

For example:

$ evrythng reactor-test run ./main.js ./reactor-config.json --api-key q2jW93I...

The script will be run and provided with all the expected global variables that are usually present in the Reactor environment in the cloud.