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

laas

v1.0.7

Published

Service wrapper around the LevelDB storage system

Downloads

11

Readme

LAAS

RESTful service wrapper around LevelDB

What is LAAS?

LevelDB as a service (LAAS), is a service wrapper around the LevelDB implementation provided by Google. This project is aimed at making it easy to start using LevelDB with a much lower barrier of entry. One way this project reduces the barrier to entry is by building out a RESTful API that provides access to the underlying functionality. HTTP request libraries are a dime a dozen, which makes communicating with this service much easier than needing to write native libraries to the underlying functionality.

Status

LAAS is currently under development. While the feature set is currently limited, there is opportunity to grow the service to be much more robust.

Why LAAS?

LevelDB is an extremely powerful key-value store, but finding language specific clients for it can be difficult. Looking around at other various LSMTree based document stores, non of them offered the simplicity and ease of use that I wanted. LevelDB was by far the easiest to get running, but it posed one interesting challenge, finding client libraries to communicate with the system. Unlike MongoDB and MySQL, LevelDB doesn't stand up it's own service layer making it extremely difficult to talk to. Instead, I decided to take a supported implementation and build out a service wrapper around the underlying functionality. In conjunction with the native LevelDB library, this service wrapper offered the service layer that I was looking for.

Get Started

Before proceeding, be sure to hae NodeJS and NPM installed. Detailed instructions on how to install NodeJS and NPM can be found in the previous link.

Dependencies

Before getting started with LAAS, it's important to make sure that all dependencies have been installed. Outside of NodeJS and NPM, LAAS only requires two other key libraries: snappy and leveldb.

Snappy

Snappy is a compression library developed by Google. Rather than trying to get the best compression, it attempts to get reasonable compression but at really high speeds.

OSX

brew install snappy

Ubuntu

sudo apt-get install build-essential 
sudo apt-get install libsnappy-dev

LevelDB

LevelDB is a high performance key-value store, backed by an LSMTree.

OSX

brew install leveldb

Ubuntu

There is currently no version of the library available in the apt-get repositories. In order to install, follow the directions as if you were installing from source.

From Source

export LEVELDB_VERSION=1.18
wget https://github.com/google/leveldb/archive/v${LEVELDB_VERSION}.tar.gz
tar -xzf v${LEVELDB_VERSION}.tar.gz
cd v${LEVELDB_VERSION}
make
sudo mv libleveldb.* /usr/local/lib
cd include
sudo cp -R leveldb /usr/local/include
sudo ldconfig

Installation

Once the dependencies have been installed, installing LAAS is simple.

npm install -g laas

Once it's installed, you need to start the laas daemon. This can be done using the start command.

laas start

When completed, this will start a web server running on *:6931. You can test this by attempting to create a database.

$ curl -X POST -d 'name=testdb' http://localhost:6931/api/v1/dbs
{"name":"testdb","keyEncoding":"utf8","valueEncoding":"utf8"}

If you want to change the encoding type, then you can add on the corresponding body.

$ curl -X POST -d 'name=jsondb&keyEncoding=json&valueEncoding=json' http://localhost:6931/api/v1/dbs
{"name":"jsondb","keyEncoding":"json","valueEncoding":"json"}

Once created, you can insert documents into the database. There are two approaches to inserting documents into the database. The first being a single document approach. This allows clients to insert documents into the database one at a time.

$ curl -X POST -d 'key=abcdefg&value=Lorem%20ipsum%20dolor%20sit%20amet.' http://localhost:6931/api/v1/dbs/testdb/docs
[{"key":"abcdefg","value":"Lorem ipsum dolor sit amet."}]

$ curl -X POST -H 'Content-Type: application/json' -d '{"key":{"name": "abcdefg"},"value":{"text": "Lorem ipsum dolor sit amet."}}' http://localhost:6931/api/v1/dbs/jsondb/docs
[{"key":{"name":"abcdefg"},"value":{"text":"Lorem ipsum dolor sit amet."}}]

The second approach allows documents to be created in batch. This approach offers a higher write throughput and is more preferred over the single document approach.

$ curl -X POST -H 'Content-Type: application/json' -d '{"docs":[{"key":"key1","value":"value1"},{"key":"key2","value":"value2"},{"key":"key3","value":"value3"}]}' http://localhost:6931/api/v1/dbs/testdb/docs
[{"key":"key1","value":"value1"},{"key":"key2","value":"value2"},{"key":"key3","value":"value3"}]

$ curl -X POST -H 'Content-Type: application/json' -d '{"docs":[{"key":{"a":"compositeKey1","b":"compositeKey2"},"value":{"a":"compositeValue1","b":"compositeValue2"}},{"key":{"a":"compositeKey3","b":"compositeKey4"},"value":{"a":"compositeValue3","b":"compositeValue4"}},{"key":{"a":"compositeKey5","b":"compositeKey6"},"value":{"a":"compositeValue5","b":"compositeValue6"}}]}' http://localhost:6931/api/v1/dbs/jsondb/docs
[{"key":{"a":"compositeKey1","b":"compositeKey2"},"value":{"a":"compositeValue1","b":"compositeValue2"}},{"key":{"a":"compositeKey3","b":"compositeKey4"},"value":{"a":"compositeValue3","b":"compositeValue4"}},{"key":{"a":"compositeKey5","b":"compositeKey6"},"value":{"a":"compositeValue5","b":"compositeValue6"}}]

Once you have documents, you can query for them as easy as a single get request. Again, this service offered two approaches to retrieving information from the database. The first allows documents to be retrieved one at a time.

$ curl http://localhost:6931/api/v1/dbs/testdb/docs/key1
{"key":"key1","value":"value1"}

The second is to be able to retrieve multiple documents at once.

$ curl 'http://localhost:6931/api/v1/dbs/testdb/docs?key=key1&key=key2'
[{"key":"key1","value":"value1"},{"key":"key2","value":"value2"}]

It's as easy as that! See the documentation section for additional operations that can be performed on the service.

Documentation

Documentation has been provided for both the command line utility and the api documentation.

Contributing

See CONTRIBUTING.md

License

See LICENSE