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

express-couchdb-router

v0.2.3

Published

An Express router which allows static content to be delivered from CouchDb.

Downloads

4

Readme

express-couchdb-router

Purpose

This is an express router which allows you to store your static files in a CouchDb database instead of in the file system. This is useful when your website has a mixture of static and dynamic content. It means the entire website is contained within the database and can easily be replicated for redundancy, scaling and offline use.

Tools are included to enable you to develop locally in the file system and then upload to the database.

Status

Alpha testing. This is still very much a "work-in-progress". Fell free to try it and make suggestions but do not use it in production just yet.

Set Up

npm install express-couchdb-router

Once installed run the ECR utility, ecr init, to initialise your workspace.

app.js

This has the Express based web app. The sample provided allows you to choose whether to run from the local static files (command line option -s or --static) or the database (command line option -d or -database).

Example

node ./app.js -s will use the static files.
node ./app.js -d will use the database.

Static Folder

This is the folder where you will develop the static files used by your website. This would not normally be copied to the production server.

NPM Scripts

The following scripts are added to the package.json:

  • static - Runs the server from the local static files.
  • localdb - Runs the server from the local database. These are implemented using npm run <script name>.

Configuration File

The configuration file, ecr-config.json, is created as part of the init process. This should be amended as needed by your particular app. The default values will get you started

{
  "localDb": { <--- Defines the local database used for testing and staging.
    "URL": "http://localhost:5984/<your app name>",
    "adminName": (optional) <--- The name of the admin user
    "adminPassword": (optional) <--- The password of the admin user
  },
  "prodDb": { <--- Defines the production database. Not used at the moment.
    "Url": (optional),
    "admin": (optional),
    "password": (optional)
  },
  "staticFolder": "./static" <--- The local folder where the static files are stored.
}

The database server is initialised as the localhost with the application name (as defined in package.json) for the database name.

Upload

The local database can be synchronised to the local static files using the command:
ecr upload
This will copy all the static files into the local database and remove any entries in the database which no longer have matching entries in the static files folder.

This allows for a staging test running from a local database before replicating the local database to the producion database.

Contributions

Pull requests accepted

Author

Mike Robertson [email protected]