ExpressJS CouchDB proxy middleware
Use cases:
- proxying client-side requests to CouchDB hosted from localhost
- disabling POST/PUT/DELETE requests on db or particular document
- etc
Usage:
const express = ;const app = ;const couchProxy = url: "http://user:password@192.168.1.100:5984" // Defaults to http://localhost:5984 entries: "documents1" "_users" "_session" // Specify your database names here. Don't forget to specify system entries like _users or _session if needed. Defaults to ["_users", "_session"] restrictMethod: "next" //"next" - will call next middleware/route, "unauthorized" - will return "401 Unauthorized", defaults to "unauthorized" { // Custom request handling logic here, You can return false to restrict request by given restrictMethod. Dont forget to return true in the end. if reqoriginalUrl == "/documents1/readonly_document" && reqmethod == "PUT" // Disable writes on /documents1/readonly_document return false; return true; };app;app;app;