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 🙏

© 2025 – Pkg Stats / Ryan Hefner

dfdb-express

v0.0.20

Published

This is a simple extension to easily expose a DocsOnFileDB through Express as a RESTful API.

Downloads

4

Readme

Build Status Codacy Badge Maintainability

DocsOnFileDB (ExpressJS connector)

This is a simple extension to easily expose a DocsOnFileDB through Express as a RESTful API.

Contents

Installation

To install this module you may run:

npm install --save dfdb-express

How to use

This code example shows a simple express server and how to set express to expose certain DocsOnFileDB:

'use strict';

//
// What port should be use?
const port = process.env.PORT || 3000;

//
// Basic required libraries.
const bodyParser = require('body-parser');
const express = require('express');
const http = require('http');
const path = require('path');

//
// Creating an express library.
const app = express();

//
// Basic middlewares.
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));

//
// Importing 'dfdb-express' middleware.
const expressConnector = require('dfdb-express').middleware;
//
// Telling express to handle database API accesses on the URI '/rest/mydb'.
// Of course 'dbname' and 'dbpath' are the basic parameters required by
// 'DocsOnFileDB' to access certain database, in this case, the one that's going
// to be exposed.
// Also, in this configuraion the collection 'my_private_collection' won't be
// exposed.
app.use(expressConnector({
    dbname: 'mydb',
    dbpath: path.join(__dirname, 'db-dir'),
    restPath: '/rest/mydb',
    hide:[
        'my_private_collection'
    ]
}));

//
// Capturing unkwnon route requests.
app.all('*', (req, res) => {
    res.status(404).json({
        message: `Path '${req.url}' was not found.`
    });
});

//
// Starting server.
http.createServer(app).listen(port, () => {
    console.log(`listening on port ${port}`);
});

Endpoints

These are endpoints provided by this connector:

  • [GET] /rest/mydb/$info Provides information about current database connection and it's assets.
  • [POST] /rest/mydb/$initializer Replaces a database initialization spec.
  • [POST] /rest/mydb/$reinitialize Triggers a check-up of a database initialization spec.
  • [POST] /rest/mydb/:collection/$createIndex?field=:name Creates a field index for a collection and indexes it.
  • [GET] /rest/mydb/:collection/$create Triggers the creation of certain collection.
  • [DELETE] /rest/mydb/:collection/$dropIndex?field=:name Drops a field index from a collection.
  • [DELETE] /rest/mydb/:collection/$drop
  • [GET] /rest/mydb/:collection/$indexes
  • [GET] /rest/mydb/:collection/$schema Retrieves a collection's schema definition.
  • [PUT] /rest/mydb/:collection/$schema Updates a collection's schema specification.
  • [POST] /rest/mydb/:collection/$truncate Remove all documents from a collection. It doesn't reset indexes.
  • [DELETE] /rest/mydb/:collection/:id
  • [GET] /rest/mydb/:collection/:id
  • [PUT] /rest/mydb/:collection/:id
  • [GET] /rest/mydb/:collection Retrieves all the information inside certain collection.
  • [POST] /rest/mydb/:collection

Basic server

If you don't want to go through all the step of creating a server but you still want to see your database in a web interfase, you may run something like this (assuming your database is at /path/to/mydb.dfdb):

dfdb-server --database /path/to/mydb

This will load this two urls:

  • http://localhost:3005/rest: RESTful access to your database.
  • http://localhost:3005/ui: Web-UI access to your database.

Licence

MIT © 2018 Alejandro Dario Simi