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

easy-db-server

v3.0.0

Published

Lite&easy database for Node.js.

Downloads

5

Readme

REST API server based on Easy DB

Easy DB logo

Lite&easy database REST server based on easy-db-node without any necessary configuration.

Include types for TypeScript.

Features

  • The same interface in Node, Web, Mobile, Server or your own environment.
  • Handling saving and removing files directly in easy-db.
  • Easy reading and updating database without any special tool.
  • MongoDB like queries for GET collection.

CLI

Install and start server in current folder

$ npx easy-db-server

Help and configurations

Usage: easy-db-server --port <port> -html ./index.html

Options:
      --help           Show help                                       [boolean]
      --version        Show version number                             [boolean]
  -p, --port           PORT                                             [number]
  -h, --html           Index HTML file                                  [string]
  -t, --easy-db-token  Security token                                   [string]
  -v, --verbose        0 - no, 1 - yes                     [number] [default: 1]
  -c, --cors           Use CORS                        [boolean] [default: true]
  -s, --size           Request size limit             [string] [default: "15MB"]

Code

Usage with easy-db-node.

import { express, useEasyDB } from "easy-db-server";
// or
const { express, useEasyDB } = require("easy-db-server");

const PORT = 80;

const app = express();

useEasyDB(app, {
  verbose: 1,
  requestSizeLimit: "15MB",
  cors: true,
  token: "tokenHash",
});

app.listen(PORT, () =>
  console.log(`Easy DB server is running at http://localhost:${PORT}.`)
);

Usage with different easy-db service

import { express, useEasyDB } from "easy-db-server";
import easyDBGoogleCloud from "easy-db-google-cloud";

const easyDB = easyDBGoogleCloud({ ... });

const app = express();
useEasyDB(app, {}, easyDB);

app.listen(80);

REST API

  • GET /api/:collection: return whole collection optionally with query, projection, sort, skip and limit
  • GET /api/:collection/:id: return one row from collection by id
  • POST /api/:collection: create row with random id string and return id
  • PUT /api/:collection/:id: replace row from collection by id
  • PATCH /api/:collection/:id: update row (shallow merge) from collection by id
  • DELETE /api/:collection/:id: remove whole row from collection by id

Easy-db API

  • GET /api/easy-db-collections: return names of collections

Token

Use header Easy-DB-Token for your token.

Upload files by REST API

Just sent to POST or PUT anywhere in the body { "type": "EASY_DB_FILE", "url": "data:image/png;base64,iVB...YI=" }. With GET you will receive { "type": "EASY_DB_FILE", "url": "/easy-db-files/j9pSCplbMx7U.png" }

Query, projection, sort, skip and limit

Easy-db-server use mingo library that allow you to use MongoDB like query, projection, sort, skip and limit. For documentation on using query and projection operators see MongoDB.

GET http://localhost:80/api/user?query={"age":{"$gt":18}}&projection={"name":1,"age":1}&sort={"name":1,"age":-1}&skip=20&limit=10

Files

  • easy-db/
    • collection1.json
    • collection1-wrong-20180912.json
  • easy-db-files/
    • j9pSCplbMx7U.png

Update DB without code

Only open file and edit them.

collection1.json

{
  "LnldbDWRXe8r": { "myRow": 1, "update": 1 },
  "UXnuhpl5RvVp": { "myRow": 2, "update": 36 }
}