This is couch-auth-proxy: a TypeScript (Hono) reverse proxy that enforces per-document ACLs in front of Apache CouchDB 3.5+. See README.md for the product model, USER-GUIDE.md for ACL modeling, and package.json for the full script list.
- Node.js 24 is installed via
nvmand made default;~/.bashrcprepends it so it wins over the system/exec-daemon/node(v22). Always run repo commands in a login shell (bash -lc '...') so Node 24 +pnpm(via Corepack) are onPATH. - Docker Engine + compose plugin are installed.
dockerdis not managed by systemd here — start it manually if not running:sudo dockerd &(it logs to the foreground). Theubuntuuser is in thedockergroup, so a fresh login shell can rundockerwithoutsudo; within an already-open shell that predates the group change, usesg docker -c '<cmd>'.
- Full stack (built image, closest to prod):
docker compose up -d --buildstarts CouchDB 3.5, a one-shotcouch-init(createsacldemoDB + demo users), and the proxy onhttp://127.0.0.1:8000. Verify with/_couch-auth-proxy/healthand/_couch-auth-proxy/ready(both return{"ok":true}). - Host dev (hot reload): publish CouchDB first with
docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d couchdb couch-init(exposes Couch on host5985), then runpnpm devwithCOUCH_URL=http://127.0.0.1:5985and the admin creds (see the "Local dev" block inREADME.md). Running the docker proxy andpnpm devat once requires differentPORTs (proxy uses 8000). - Demo users (created by
couch-init):alice/alice-pass(rolereaders),bob/bob-pass(rolewriters), adminadmin/password. A document withcreator: "<user>"is private to that user; missing ACL fields make it readable by any authenticated DB member.
pnpm lint,pnpm fmt:check,pnpm typecheck,pnpm test(unit) need no running services.pnpm test:integrationrequires the docker stack up first (docker compose up -d --build); it hits the proxy athttp://127.0.0.1:8000.pnpm test:perfis the ACL load harness (multi-client Pouch sync + HTTP r/w ops/sec). Prefer the dev overlay so direct Couch is on5985for overhead compare:docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d --build. Not part of CI.- Request phase profiling: set
PROFILE=true(compose overlaydocker-compose.profile.yml, orpnpm docker:up:profile). ScrapesGET /_couch-auth-proxy/profile(auth / acl / aclMiss / upstream / filter + process memory / resource sizes). Convenience:pnpm test:perf:profile. Host CPU profiles: build thenpnpm start:profile(writes underprofiles/). - Memory stability soak (opt-in):
pnpm test:perf:memorybrings up the profile overlay (PROFILE=true,NODE_OPTIONS=--expose-gc), runs a multi-minute steady-state ACL load while scraping heap/rss trends, and writestest/perf/last-memory-report.md. Tunable viaPERF_MEMORY_DURATION_SEC(default 300).
pnpm installprints an ignored-build-script warning forleveldown(a transitive PouchDB dep). This is harmless — integration tests usepouchdb-adapter-memory, so the nativeleveldownbuild is not needed.- The proxy fails closed: a down CouchDB or ACL follower makes
/_couch-auth-proxy/readyreturn503. If integration tests fail on readiness, confirm the compose stack is healthy (docker compose ps).