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

catenis-api-emulator

v1.0.0

Published

Catenis API emulator meant to be used for testing Catenis API clients.

Downloads

4

Readme

Catenis API Emulator

This Node.js application is meant to be used for testing Catenis API clients.

Installation

The application can be installed globally or under the project of the Catenis API client being tested.

To install it globally:

npm install -g catenis-api-client

To install it under the Catenis API client's project:

npm install --save-dev catenis-api-client

Usage

When the application is run, two HTTP servers are started at the localhost address:

  • API server: this should be used in place of the actual Catenis API in the test cases of a Catenis API client.
  • Command server: used to control how the API serer should behave in relation to the received requests, via a simple REST API.

For a list of the available command line options:

catenis-api-client --help

Command REST API

Add one or more Catenis device credentials

Method: POST

Path: /device-credentials

Body:

  • A JSON adhering to the following schema:
({
    deviceId: string,
    apiAccessSecret: string
} | [
    {
        deviceId: string,
        apiAccessSecret: string
    }
])
  • Example (single device):
{
  "deviceId": "drc3XdxNtzoucpw9xiRp",
  "apiAccessSecret": "4c1749c8e86f65e0a73e5fb19f2aa9e74a716bc22d7956bf3072b4bc3fbfe2a0d138ad0d4bcfee251e4e5f54d6e92b8fd4eb36958a7aeaeeb51e8d2fcc4552c3"
}
  • Example (multiple devices):
[
  {
    "deviceId": "drc3XdxNtzoucpw9xiRp",
    "apiAccessSecret": "4c1749c8e86f65e0a73e5fb19f2aa9e74a716bc22d7956bf3072b4bc3fbfe2a0d138ad0d4bcfee251e4e5f54d6e92b8fd4eb36958a7aeaeeb51e8d2fcc4552c3"
  },
  {
    "deviceId": "d8YpQ7jgPBJEkBrnvp58",
    "apiAccessSecret": "267a687115b9752f2eec5be849b570b29133528f928868d811bad5e48e97a1d62d432bab44803586b2ac35002ec6f0eeaa98bec79b64f2f69b9cb0935b4df2c4"
  }
]

Retrieve the current Catenis device credentials

Method: GET

Path: /device-credentials

Set the HTTP context

Method: POST

Path: /http-context

Body:

  • A JSON adhering to the following schema:
{
    expectedRequest: {
        httpMethod: ('GET' | 'POST'),
        apiMethodPath: string,
        headers?: Object<string, (string | null)>,
        data?: string, /* JSON */
        authenticate: boolean
    },
    requiredResponse?: ({
        data: string /* JSON */
    } | {
        statusCode: Number,
        errorMessage?: String
    })
}
  • Example (success response):
{
  "expectedRequest": {
    "httpMethod": "POST",
    "apiMethodPath": "messages/log",
    "data": "{\"message\":\"Test message #1\"}",
    "authenticate": true
  },
  "requiredResponse": {
    "data": "{\"messageId\":\"mdx8vuCGWdb2TFeWFZd6\"}"
  }
}
  • Example (error response):
{
  "expectedRequest": {
    "httpMethod": "POST",
    "apiMethodPath": "messages/log",
    "data": "{\"message\":\"This is another test message\"}",
    "authenticate": true
  },
  "requiredResponse": {
    "statusCode": 400,
    "errorMessage": "Not enough credits to pay for log message service"
  }
}
  • Example (request with data compression):
{
  "expectedRequest": {
    "httpMethod": "POST",
    "apiMethodPath": "messages/log",
    "headers": {
      "Content-Encoding": "deflate"
    },
    "data": "{\"message\":\"This is a long message, long enough to make sure that it will be compressed before being sent. If it is not long enough, the message will not be compressed.\"}",
    "authenticate": true
  },
  "requiredResponse": {
    "data": "{\"messageId\":\"mBQjBLCATBrRxST3Gu4F\"}"
  }
}

Retrieve the current HTTP context

Method: GET

Path: /http-context

Set the WebSocket notification context

Method: POST

Path: /notify-context

Body:

  • A JSON adhering to the following schema:
Object<string, Object<string, {
  data: string, /* JSON */
  timeout?: number
}>>

Where the key of the outer dictionary is a Catenis virtual device ID, and the key of the inner dictionary is a Catenis notification event.

  • Example:
{
  "drc3XdxNtzoucpw9xiRp": {
    "new-msg-received": {
      "data": "{\"messageId\":\"mNEWqgSMAeDAmBAkBDWr\",\"from\":{\"deviceId\":\"dnN3Ea43bhMTHtTvpytS\",\"name\":\"deviceB\",\"prodUniqueId\":\"XYZABC001\"},\"receivedDate\":\"2018-01-29T23:27:39.657Z\"}",
      "timeout": 5
    }
  }
}

Retrieve the current WebSocket notification context

Method: GET

Path: /notify-context

Close all WebSocket notification channels

Method: POST

Path: /notify-close

Body: none

Retrieve application info

Method: GET

Path: /info

Close the application

Method: POST

Path: /close

Body: none

License

This application is released under the MIT License. Feel free to fork, and modify!

Copyright © 2023, Blockchain of Things Inc.