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

digger-rest

v1.1.3

Published

REST api server for digger queries

Downloads

5

Readme

digger-rest

REST API server for digger-level

install

Docker container:

$ docker pull binocarlos/digger-rest

Node CLI program:

$ npm install -g digger-rest

Node library:

$ npm install digger-rest

usage

Docker container:

$ docker run -d \
  -v /tmp/diggerdata:/data/db \
  -p 8080:80 \
  binocarlos/digger-rest

Node CLI program:

$ digger-rest --port 8080 --file /tmp/diggerdata

Node library:

var level = require('level')
var sub = require('level-sublevel')
var Router = require('digger-rest')

var leveldb = sub(level('/tmp/digger'))
var router = Router(db)
server = http.createServer(router)
server.listen(8080, function(){
  t.ok(true, 'server listening')
  t.end()
})

routes

GET /version

get the app version

GET /item/:id

get an item by it's diggerid

request({
  url:'http://127.0.0.1:8080/path/shop/food/folder1/item1',
  method:'GET',
  json:true
}, function(err, res){
  // ...
})

results:

[
    {
        "name": "Red Apple",
        "_digger": {
            "id": "mything",
            "inode": "item1",
            "class": [
                "apple"
            ],
            "tag": "fruit",
            "diggerid": "0d43987f5d690e10d704583fe30bf75a",
            "path": "/mydb/shop/food/folder1",
            "created": 1469557183129
        },
        "color": "red",
        "_data": {}
    }
]

POST /item/:id

add an item to a diggerid

const FIXEDID = '17dcd3b0ba3411e2b58d91a4d58f5088'
const addData = {
  name:'Folder',
  _digger:{
    tag:'folder',
    inode:'addedcities',
    class:['addcity'],
    id:'addcity'
  }
}

request({
  url:'http://127.0.0.1:8080/item/' + FIXEDID,
  method:'POST',
  json:true,
  body:addData
}, function(err, res){
  // ...
})

results:

[
    {
        "name": "Folder",
        "_digger": {
            "tag": "folder",
            "inode": "addedcities",
            "class": [
                "addcity"
            ],
            "id": "addcity",
            "diggerid": "73d1fab78e5da0bc4c321582fd2d2c2d",
            "path": "/mydb/cities/726acf",
            "created": 1469557266443
        },
        "_data": {}
    }
]

PUT /item/:id

update an item

const FIXEDID = '17dcd3b0ba3411e2b58d91a4d58f5088'
var updatedata = {
  size:120,
  color:'blue',
  _digger:{
    id:"places2"
  }
}

request({
  url:'http://127.0.0.1:8080/item/' + FIXEDID,
  method:'PUT',
  json:true,
  body:updatedata
}, function(err, res){
  // ...
})

this does a deep merge of the data you send

results:

[
    {
        "_digger": {
            "tag": "folder",
            "class": [
                "hello"
            ],
            "id": "places2",
            "diggerid": "17dcd3b0ba3411e2b58d91a4d58f5088",
            "inode": "77e8b5",
            "path": "/mydb/cities",
            "created": 1469557371497
        },
        "size": 120,
        "color": "blue",
        "_data": {}
    }
]

DELETE /item/:id

delete an item

const FIXEDID = '17dcd3b0ba3411e2b58d91a4d58f5088'
request({
  url:'http://127.0.0.1:8080/item/' + FIXEDID,
  method:'DELETE',
  json:true
}, function(err, res){
  // ...
})

GET /path/:path

get an item at a path

POST /path/:path

add an item to a path

GET /select/:path?selector=

select items from a context

if the selector is blank it means select the item at the path

otherwise it means run the selector with the path as the context

request({
  url:'http://127.0.0.1:8080/select/cities',
  method:'GET',
  qs:{
    selector:'country.big city.north > area'
  },
  json:true
}, function(err, res){
  // ...
})

GET /keys

get all the keys in the database