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

rest-flat-file-db

v1.2.1

Published

REST API for flat-file-db

Downloads

8

Readme

rest-flat-file-db

Build Status dependencies devDependencies styled with prettier

REST API for flat-file-db powered by koa2

About

This is a tiny module which extends the lightweight flat-file-db key-value based to-go datastorage. It might be useful for small projects (e.g. hackathon).

Usage

As standalone instance

# install the module globally
$ npm install -g rest-flat-file-db

# start the module with default parameters
$ rest-flat

# OR start it with custom parameters
$ PORT=3333 DB=/tmp/mydatabase rest-flat

As module

$ npm install rest-flat-file-db --save


// index.js

const restflat = require('rest-flat-file-db');
const flatdb = require('flat-file-db');

const app = restflat(flatdb.sync('/tmp/mydatabase'));

// this is just a normal koa2 app and it is ready to launch.

app.listen();

Hint: You can pass your own koa app as well if you want to make some setup on it before the rest-flat endpoints will be initialized. (e.g. Authentication) This second parameter is optional. In default case the koa instance will be created by the rest-flat-file-db itself.

REST API

GET /

200 and a single object contains all key-value pairs of the database

GET /:key

200 (if the key could be found, otherwise 404) and the value of :key

POST /:key

409 if key already exists in the database otherwise 201 and the body of the post will be stored with the key in the db (response.headers['location'] contains the url to the item)

PUT /:key

200 (if the key could be found, otherwise 404) and the updated item with its new content

PATCH /:key

200 (if the key could be found, otherwise 404) and the merged (with Object.assign call) item with its new content

DELETE /:key

200 (if the key could be found, otherwise 404) and the deleted item from the db (it acts like a pop call on a stack)

POST /

201 and the body of the post will be stored with a generated key in the db (response.headers['location'] contains the url to the item)