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

simsl

v0.2.1

Published

A command-line tool that emulates a Caldera StreamLive server.

Downloads

10

Readme

simsl

simulatorstreamlive (simsl) is a command line utility that emulates a Caldera StreamLive API server, but locally. Use it to quickly develop your service without requiring a real server or domain name. It is ideally used in conjunction with the StreamLive SDK.

You need to have node.js and npm installed on your machine. To install simsl, run

npm install -g simsl

Starting the emulator

Start a session by running the simsl command anywhere. The emulator will create a configuration file for itself wherever you are running the command, named simsl.json. You can change the name of the file by providing it as an argument to the command, like simsl my-configuration.json.

You can alter the configuration file while the emulator is running and it will pick up the changes on the fly.

Once started, press enter to fire a new request or type exit to stop the emulator.

Emulating requests

The configuration file has a value named webhook; change this to match the URL that you use in your service. If for example your service is running on localhost:4000 and the route for StreamLive requests is /submit, set webhook to http://localhost:4000/submit.

The content of the request is structured exactly like one from the StreamLive API server. This means that by default, you will only receive two fields: _id and _token.

_id is normally a form ID, but with simsl it is completely made up. The _token field is an actual JWT, albeit it won't work on production servers. You can use it to verify incoming requests by verifying the token against the certificate that is provided with simsl.

Next, you'll want to emulate the tags that your service expects to receive. This is easily done by providing them as an array in the tags field of the configuration file, for example "tags": ["first-tag", "second-tag"].

Advanced tags

By default, the values of your tags will be random phrases. You can specify the type of data you want to receive for each tag by slightly altering the format:

"tags": {
	"first-tag": "integer",
	"second-tag": "date"
}

As you can see, the key is the tag name, and the value is a value type. The following types are supported:

  • string
  • integer
  • float
  • bool
  • date
  • file

You can also define exactly what value you want, as long as it's not one of the reserved keywords. So the following configuration:

"tags": {
	"first-tag": "My first tag value",
	"second-tag": false
}

would send requests with the two tags set to the exact values "My first tag value" and false.

As you may be aware, a tag can be used on several fields; when this happens, you would receive the tag's values as an array. You can emulate this behavior by specifying an array for a tag value:

"tags": {
	"first-tag": ["integer", "integer", "string"]
}

The values inside the array follow the same rules as described above.

Multiple forms

By default, you will only receive one form per request. if you'd like to support multiple forms input in your service, you can change the form_count configuration value to the number of forms you'd like to receive.

Echo server

The real StreamLive API server will send requests to a service webhook, but it is also capable of receiving API calls. While the emulator doesn't go as far as giving sensible responses to API calls, it has a simple echo server that will log every request it receives and reply with a status code 200.

By default, the emulator will run a server on localhost:4989. This means that you can send requests to http://localhost:4989 and they will show up in the console. You can change the host and the port by using the server_host and server_port configuration variables.

Lastly, you can turn this echo server off entirely by setting echo to false in the configuration.