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

tcp-log-server

v11.0.3

Published

serve an append-only log over TCP

Downloads

13

Readme

Serve an append-only log over TCP.

  • Uses a dead-simple, JSON-based protocol.
  • Stores entries as content-addressed blobs.
  • Persists to disk by default.
npm install --global tcp-log-server
tcp-log-server

Logs

The server uses pino logging. To improve console log output:

npm install --global pino
tcp-log-server | tee server.log | pino

Environment

Configure tcp-log-server with environment variables:

  • PORT for TCP
  • BLOBS directory for entry JSON files, named by hash, or memory to store in memory
  • FILE for the list of entries

Node.js

The package exports a factory function. Given a pino log, a file path, an abstract-blob-store, and an EventEmitter, it returns a TCP connection handler function suitable for net.createServer(handler). You may also provide a hash function and hash length.

Protocol

The server accepts TCP connections. It enables keep-alive on each socket. All messages are newline-delimited JSON objects. tcp-log-client provides a high-level interface.

Clients can send:

Read

{"from":1,"read":5}

On receipt, the server will begin sending up to read log entries with indices greater than or equal to from, in ascending-index order. (The lowest possible index is 1.)

Each entry will be sent like:

{"index":"1","entry":{"some":"entry"}}

Servers may report errors reading specific log entries:

{"index":45,"error":"some-error"}

If the server reaches the head of its log before sending read entries, it will send:

{"current":true}

Once the server has sent read entries, it will report the index of the head of its log:

{"head":100}

Write

{"id":"some-id","entry":{"arbitrary":"data"}}

require('uuid').v4(), with the uuid package, is an easy way to generate id strings.

Once successfully appended to the log, the server will confirm the index of the newly appended entry.

{"id":"some-id","index":44}

If there is an error, the server will instead respond:

{"id":"some-id-string","error":"error-string"}