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

skvs

v0.4.3

Published

Simple Key Value Store

Downloads

3

Readme

A simple key/value store based on node

skvs is a simple key/value store system which is simple to operate. Coded in javascript and based on express. It exposes a standard REST api to store schema-less JSON data.

skvs can either store in volatile memory or on the filesystem for permanent storage.

It also provides a 'real-time' update notification facility based on long-polling.

Install

To install globally, using npm:

npm install -g skvs

To just give it a try:

git clone https://github.com/jdmichaud/skvs && cd skvs
npm install
./skvs.js

Sample usage:

Once skvs is running:

$ # Create books
$ curl -sL -w'\n' -X POST -d '{ "author": "Arthur C. Clarke", "title": "Childhoods End" }' localhost:12000/api/book/ -H 'Content-type: application/json'
{"author":"Arthur C. Clarke","title":"Childhoods End","id":1}
$ curl -sL -w'\n' -X POST -d '{ "author": "Michael Crichton", "title": "The Andromeda Strain" }' localhost:12000/api/book/ -H 'Content-type: application/json'
{"author":"Michael Crichton","title":"The Andromeda Strain","id":2}
$ curl -sL -w'\n' -X POST -d '{ "author": "Arthur C. Clarke", "title": "Rendez-Vous With Rama" }' localhost:12000/api/book/ -H 'Content-type: application/json'
{"author":"Arthur C. Clarke","title":"Rendez-Vous With Rama","id":3}
$ curl -sL -w'\n' -X POST -d '{ "author": "Joe Haldemann", "title": "The Forever War" }' localhost:12000/api/book/ -H 'Content-type: application/json'
{"author":"Joe Haldemann","title":"The Forever War","id":4}
$ # Retrieve the list of books
$ curl -sL -w'\n' localhost:12000/api/book/ -H 'Content-type: application/json'
[{"author":"Arthur C. Clarke","title":"Childhoods End","id":1},{"author":"Michael Crichton","title":"The Andromeda Strain","id":2},{"author":"Arthur C. Clarke","title":"Rendez-Vous With Rama","id":3},{"author":"Joe Haldemann","title":"The Forever War","id":4}]
$ # Retrieve list according to a criteria
$ curl -sGL -w'\n' localhost:12000/api/book/ --data-urlencode "author=Arthur C. Clarke"
[{"author":"Arthur C. Clarke","title":"Childhoods End","id":1},{"author":"Arthur C. Clarke","title":"Rendez-Vous With Rama","id":3}]
$ # Typo in the author's name? replace an existing book
$ curl -sL -w'\n' -X POST -d '{ "author": "Joe Haldeman", "title": "The Forever Wa" }' localhost:12000/api/book/4/ -H 'Content-type: application/json'
{"author":"Joe Haldeman","title":"The Forever Wa","id":4}

Real-time update

To be notified of changes on a resource, GET the resource with the ?watch option this way:

curl -sL -w'\n' localhost:12000/api/book?watch -H 'Content-type: application/json'

This will block until a change is performed on that resource. In another terminal, perform a change to the request:

curl -sL -w'\n' -X POST -d '{ "author": "Joe Haldeman", "title": "The Forever War" }' localhost:12000/api/book/4/ -H 'Content-type: application/json'

The first command will return with the updated list:

[{"author":"Arthur C. Clarke","title":"Childhoods End","id":1},{"author":"Michael Crichton","title":"The Andromeda Strain","id":2},{"author":"Arthur C. Clarke","title":"Rendez-Vous With Rama","id":3},{"author":"Joe Haldeman","title":"The Forever War","id":4}]

Usage

To launch with all the default value:

$ skvs
server listening on port 127.0.0.1:12000 using memory store

By default, skvs will only accept local connections and will use the memory as storage.

To launch on a specific host and port

$ skvs --host 0.0.0.0 --port 12345
server listening on port 0.0.0.0:12000 using memory store

To launch skvs with the filesystem for storage

$ skvs --host 0.0.0.0 --port 12345 --storage=/tmp/data
server listening on port 0.0.0.0:12000 using filesystem store on /tmp/data

To launch skvs with a custom url prefix

$ skvs --prefix myapp
server listening on port 127.0.0.1:12000 using memory store
$ curl -sL -w'\n' localhost:12000/myapp/some-resource/

Development

To participate in skvs development, clone the repository:

git clone https://github.com/jdmichaud/skvs

And submit a pull request.

All development shall be covered by unit tests. To run the test:

npm test