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

liftstream

v0.0.3

Published

streaming interface for db adam api

Downloads

10

Readme

Liftstream

Turns the Deutsche Bahn ADAM API into an Event Emitter or a Server for Server Sent Events and Websocket Stream.

Install

Simply npm install liftstream.

Usage as Library

Liftstream emits an event every time the state of a lift changes.


var liftstream = require("liftstream");

var stream = new liftstream({
	statefile: "/tmp/statefile.json", // save elevator states here
	interval: "5m",                   // adam api polling interval
	dev: false                        // send fake events for testing
});

stream.on("data", function(data){
	console.log("Lift Number "+data.equipmentnumber+" is now "+data.state);
});

stream.on("error", console.error);

Usage as Server

Liftstream may run as an HTTP service and provide all events as Server Sent Events and Websocket Messages.

First create your own config.js from config.js.dist. Then you can start the server with node server.js or npm start. Please be reasonable with the interval value.

The Interfaces are http://localhost:3000/stream.sse for Server Sent Events and ws://localhost:3000/stream.ws for the Websocket.

Every message consists of a single JSON encoded object.

Since the data changes very little, there is a developer mode, which returns a fake event on every update without other changes. It's activated by setting config.dev to true in config.js.

You can test your Server with wscat --connect wss://server:port/stream.ws from the ws module.

License

Unlicense