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

level-connect

v0.8.0

Published

Connect to a multi handle sublevel enabled db over http

Downloads

9

Readme

level-connect

Connect to a multi handle sublevel enabled leveldb over http

Getting Started

Level-connect doesn’t really care whether it is global or not, but the easiest way (although probably least useful) to get started is to install it globally

npm i -g level-connect

Control the server instance with environment variables and fire it up

$ CONNECT_PORT=5000 connect

Logs use bunyan so any of the tooling should let you inspect the logs.

Party party

The underlying db is a level-party instance, although it is also sublevelled. This means you can access the db from multiple processes, all on different ports.

$ CONNECT_PORT=5000 ./bin/connect
$ CONNECT_PORT=5001 ./bin/connect
$ curl -X POST \
  -H 'X-LEVEL-CONNECT: <client_id>' \
  -H 'Content-Type: application/json' \
  -d '{"foo":"bar"}' \
  localhost:5000/users/foo

> 201 {"body":"ok"}

$ curl -X GET \
  -H 'X-LEVEL-CONNECT: <client_id>' \
  localhost:5001/users/foo

> 200 {"foo":"bar"}

$ curl -X DELETE \
  -H 'X-LEVEL-CONNECT: <client_id>' \
  localhost:5001/users/foo

> 200 {"body":"ok"}

$ curl -X GET \
  -H 'X-LEVEL-CONNECT: <client_id>' \
  localhost:5001/users/foo

> 404 {"foo":"bar"}

API

Control the server instance with environment variables

CONNECT_PORT

default 5000

The port to attach to

CONNECT_PATH

default HOME/.level-connect.lev

The path to the db to connect to

DEBUG

default false

If true will whack out some extra logs

HTTP API

Negotiating the handshake

Level-connect implements a fairly crude token based authentication model using custom headers. To grab a new token use /new

POST /new

$ curl -i -X POST -H 'X-LEVEL-CONNECT: new' host:port/new

201
{"id":"ID-STRING"}

The id token should be used in the X-LEVEL-CONNECT header for all subsequent requests.

Tokens stay fresh for 3 days and are refreshed with each use.

POST /:sublevel/:key

Puts a single value into a specific sublevel at key

$ curl -i -X POST \
  -H 'X-LEVEL-CONNECT: <id>' \
  -H 'Content-Type: application/json' \
  -d '{"name":"Josh","scopes":"user"}'
  host:port/users/josh

201
{"body":"OK"}

GET /:sublevel/:key

Grabs a single value from sublevel at key

$ curl -i -X GET \
  -H 'X-LEVEL-CONNECT: <id>' \
  host:port/users/josh

200
{"name":"Josh","scopes":"user"}

DELETE /:sublevel/:key

Deletes a single value from sublevel at key

$ curl -i -X DELETE \
  -H 'X-LEVEL-CONNECT: <id>' \
  host:port/users/josh

204

POST /:sublevel

Batches many values to the sublevel

$ curl -i -X POST \
  -H 'X-LEVEL-CONNECT: <id>' \
  -H 'Content-Type: application/json' \
  -d '[{"name":"Josh","scopes":"user"},{"name":"Jane","scopes":"admin"}]'
  host:port/users

201
{"body":"OK"}

GET /:sublevel

Streams many values from the sublevel

$ curl -i -X GET \
  -H 'X-LEVEL-CONNECT: <id>' \
  host:port/users

200
{"name":"Josh","scopes":"user"}
{"name":"Jane","scopes":"admin"}