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

albert

v0.1.0

Published

An HTTP event server in Node.js

Downloads

5

Readme

albert - managing events no matter the language

Image

albert is an event-message server written in Node.js to be plugged into Node's HTTP server module. It allows for sending events across several applications programming languages.

albert is implemented as a middleware handler(based on Connect) and an accompanying middleware plugin.

How it works

Albert strives to make the following possible:


// Firing an event in Node.js
object.emit("event_name", data);

// Capturing the same event in C#
Albert.On += (object sender, AlbertEventArgs e) => {
	if(e.EventName == "event_name") {
		Console.WriteLine("Win win!");
	}
};

To send and capture events between different programs, in different languages, from different locations. This is made possible by using a webserver(for easy configuration and maximum compatability) as a message handler.

How to serve

First, setup the server by using one of either method:

Node.js middleware
var albert = require('albert')
, http = require('http');
var app = albert() //the middleware handler
	.use(albert.eventHandler()); // The event handler plugin, does not fire next(), so keep at bottom of stack

http.createServer(app).listen(30301, "127.0.0.1");
Node.js with Express
var albert = require('albert')
, http = require('http')
, express = require('express');
var app = express();
app.use(albert.eventHandler()); // The event handler plugin, does not fire next(), so keep at bottom of stack
app.listen(30301);
Server(install via npm install -g)
albert-server -h 127.0.0.1 -p 30301

Then, use sample code from https://github.com/ArmedGuy/albert-clients or write your own wrapper, and specify the server that was setup

Specification

Note: EVENT_NAME_OR_MASK_* can use wildcards in the form of an asterisk(*)

Implemented

/listen/EVENT_NAME_OR_MASK_*

Opens an HTTP stream without time, with Connection: keep-alive and Transfer-Encoding: chunked, to listen for incoming events matching EVENT_NAME_OR_MASK_*. All output is in the form of an JSON object followed by CRLF(\r\n). The first line after opening a connection always looks like:

{"listening": true, "event": "EVENT_NAME_OR_MASK_*", "id": "listener_id"}

Stream is open until connection is lost by the client

Available aliases for /listen/:

  • /on/

/callback/EVENT_NAME_OR_MASK_*/base64_encode(callback_url)

Registers a HTTP POST callback URL that will be called when incoming events match EVENT_NAME_OR_MASK_*. The return data is an raw JSON object in the format:

{"event":"event_name", "id":"event_id", "status":"OK or ERROR or CUSTOM", "progress": "less or equal to 100", "data": "mixed data from event"}

Available aliases for /callback/:

  • None

/emit/EVENT_NAME (POST version)

Emits an event on the server, with parameters in the form of an JSON object as the POST data. The data must not be empty, if not passing arguments(such as status, ok or data), pass an empty JSON object

Format for POST data:

{"status": "OK or ERROR or CUSTOM", "progress": "less or equal to 100", "data": "mixed data from event"}
  • If status is left out, it defaults to OK.
  • If progress is left out, it defaults to 100.
  • If data is left out, it defaults to empty.

Returns an JSON object containing the id of the event, incase you want to update an event's progress(read more)

Available aliases for /emit/:

  • /fire/

/emit/EVENT_NAME?status=OK&progress=100&data=Hi (GET version)

Emits an event on the server, with parameters in the form of GET variables

  • If status is left out, it defaults to OK.
  • If progress is left out, it defaults to 100.
  • If data is left out, it defaults to empty.

Returns an JSON object containing the id of the event, incase you want to update an event's progress(read more)

Available aliases for /emit/:

  • /fire/

/update/EVENT_ID (POST version)

Updates an existing event on the server, with parameters in the form of an JSON object as the POST data. The data must not be empty, if not passing arguments(such as status, ok or data), pass an empty JSON object

  • If status is left out, it defaults to last value.
  • If progress is left out, it defaults to last value.
  • If data is left out, it defaults to last value.

Available aliases for /update/:

  • /push/

/update/EVENT_ID?status=OK&progress=100&data=Hi (GET version)

Updates an existing event on the server, with parameters in the form of GET variables

  • If status is left out, it defaults to last value.
  • If progress is left out, it defaults to last value.
  • If data is left out, it defaults to last value.

Available aliases for /update/:

  • /push/

Planned

/link/base64_encode(albert_server_url)

Link the handling albert server together with another albert server, making them share events