{"_id":"@amirulabu/couchdb-better-auth","_rev":"4-afe8c933698e5b4c953f4ad9c7b03e04","name":"@amirulabu/couchdb-better-auth","dist-tags":{"latest":"0.1.6"},"versions":{"0.1.0":{"name":"@amirulabu/couchdb-better-auth","version":"0.1.0","keywords":["better-auth","couchdb","adapter","authentication"],"author":{"name":"@amirulabu"},"license":"ISC","_id":"@amirulabu/couchdb-better-auth@0.1.0","maintainers":[{"name":"amirulabu","email":"amirulabu@gmail.com"}],"homepage":"https://github.com/amirulabu/couchdb-better-auth#readme","bugs":{"url":"https://github.com/amirulabu/couchdb-better-auth/issues"},"dist":{"shasum":"93e20904bb6c9c13c43d20aa1c3be96e528e9717","tarball":"https://registry.npmjs.org/@amirulabu/couchdb-better-auth/-/couchdb-better-auth-0.1.0.tgz","fileCount":6,"integrity":"sha512-lAZAb4xdGCIwWPPGAoKvI+H5ESC5/vgW46Mu9ywGLeSpsas6FEHwMkSQqSm/Z+ha2aHNujcJGOvkBTkFpC4bjw==","signatures":[{"sig":"MEUCIAqAAgaRFRBZTow3ptos3jrnn4nf48O8fixEi8sLtscCAiEA/QN+WzANRSQk4TOlRebk+2whBYh7xLI5rp4iO/5Owvk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":72822},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"845520c7e8bf31f048eb8cd9ec9718cdd8ab4e2c","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"tsc -p tsconfig.build.json","prepublishOnly":"npm run build"},"_npmUser":{"name":"amirulabu","email":"amirulabu@gmail.com"},"repository":{"url":"git+https://github.com/amirulabu/couchdb-better-auth.git","type":"git"},"_npmVersion":"10.9.3","description":"Better-Auth adapter for CouchDB","directories":{"example":"example"},"_nodeVersion":"22.19.0","dependencies":{"nano":"^10.1.2"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.0.0","@types/nano":"^7.0.0"},"peerDependencies":{"better-auth":"*"},"_npmOperationalInternal":{"tmp":"tmp/couchdb-better-auth_0.1.0_1766847816539_0.2047471006437418","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@amirulabu/couchdb-better-auth","version":"0.1.1","keywords":["better-auth","couchdb","adapter","authentication"],"author":{"name":"@amirulabu"},"license":"ISC","_id":"@amirulabu/couchdb-better-auth@0.1.1","maintainers":[{"name":"amirulabu","email":"amirulabu@gmail.com"}],"homepage":"https://github.com/amirulabu/couchdb-better-auth#readme","bugs":{"url":"https://github.com/amirulabu/couchdb-better-auth/issues"},"dist":{"shasum":"5a49cbb5c3b3a0427e63fae36bcd4ad8ec90ade6","tarball":"https://registry.npmjs.org/@amirulabu/couchdb-better-auth/-/couchdb-better-auth-0.1.1.tgz","fileCount":10,"integrity":"sha512-jsUMC1Oupcy+Cr1o8qzS7icX1VSXRmxnuJWBhzsuOPTYQ7emfbSkjX1+ozul1HUelFUOyfb6hP/xREK4wlwDuQ==","signatures":[{"sig":"MEUCIQDfyjc24QzGe7fqIVmFzN8qaZ7hl8JeKTf4fxdLPJcK9gIgdvqAfNustfRj/4zk67uoZ2wbtM2c+Ra5aTGhjfyxDRM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":105902},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"5cbf28a20a1e6c177d11ad47cca42a9d05b611c0","scripts":{"test":"vitest run","build":"tsc -p tsconfig.build.json","test:watch":"vitest","prepublishOnly":"npm run build"},"_npmUser":{"name":"amirulabu","email":"amirulabu@gmail.com"},"repository":{"url":"git+https://github.com/amirulabu/couchdb-better-auth.git","type":"git"},"_npmVersion":"10.9.3","description":"Better-Auth adapter for CouchDB","directories":{"example":"example"},"_nodeVersion":"22.19.0","dependencies":{"nano":"^10.1.2"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^1.6.0","typescript":"^5.0.0","@types/nano":"^7.0.0","@types/node":"^20.0.0","better-auth":"^1.4.7"},"peerDependencies":{"better-auth":"*"},"_npmOperationalInternal":{"tmp":"tmp/couchdb-better-auth_0.1.1_1766852183229_0.7318045677372733","host":"s3://npm-registry-packages-npm-production"}},"0.1.5":{"name":"@amirulabu/couchdb-better-auth","version":"0.1.5","keywords":["better-auth","couchdb","adapter","authentication"],"author":{"name":"@amirulabu"},"license":"ISC","_id":"@amirulabu/couchdb-better-auth@0.1.5","maintainers":[{"name":"amirulabu","email":"amirulabu@gmail.com"}],"homepage":"https://github.com/amirulabu/couchdb-better-auth#readme","bugs":{"url":"https://github.com/amirulabu/couchdb-better-auth/issues"},"dist":{"shasum":"ab56d2ec0e4ec05009ea32af5e5c24a75612ca5b","tarball":"https://registry.npmjs.org/@amirulabu/couchdb-better-auth/-/couchdb-better-auth-0.1.5.tgz","fileCount":10,"integrity":"sha512-euOQ3JUC7IbrG3iTv0eWQC0MCnSenh9PmJQomp/WLQVETLz7vQO1m2AlWCNvtFNB5CKMDgK9A5DIfVGiuhLPuA==","signatures":[{"sig":"MEYCIQDmz6XE5zl/sYd+QriWkm/cNUKuL26pXM4YndKb5pVOvgIhALXWNFPvgaSnzhQZ+u79ABbovwX1hv3SlUYCsTPxTTZn","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@amirulabu%2fcouchdb-better-auth@0.1.5","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":105862},"main":"./dist/index.js","type":"module","_from":"file:amirulabu-couchdb-better-auth-0.1.5.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"scripts":{"test":"vitest run","build":"tsc -p tsconfig.build.json","test:watch":"vitest"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:a4ddab85-3bd4-4355-8e4a-d6be69257406"}},"_resolved":"/tmp/56f0adc485b29e7220760387aae2f5b1/amirulabu-couchdb-better-auth-0.1.5.tgz","_integrity":"sha512-euOQ3JUC7IbrG3iTv0eWQC0MCnSenh9PmJQomp/WLQVETLz7vQO1m2AlWCNvtFNB5CKMDgK9A5DIfVGiuhLPuA==","repository":{"url":"git+https://github.com/amirulabu/couchdb-better-auth.git","type":"git"},"_npmVersion":"11.6.2","description":"Better-Auth adapter for CouchDB","directories":{"example":"example"},"_nodeVersion":"24.12.0","dependencies":{"nano":"^10.1.2"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^1.6.0","typescript":"^5.0.0","@types/nano":"^7.0.0","@types/node":"^20.0.0","better-auth":"^1.4.7"},"peerDependencies":{"better-auth":"*"},"_npmOperationalInternal":{"tmp":"tmp/couchdb-better-auth_0.1.5_1766853253787_0.4148495171105302","host":"s3://npm-registry-packages-npm-production"}},"0.1.6":{"name":"@amirulabu/couchdb-better-auth","version":"0.1.6","description":"Better-Auth adapter for CouchDB","type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"keywords":["better-auth","couchdb","adapter","authentication"],"dependencies":{"nano":"^10.1.2"},"devDependencies":{"@types/nano":"^7.0.0","@types/node":"^20.0.0","better-auth":"^1.4.7","typescript":"^5.0.0","vitest":"^1.6.0"},"peerDependencies":{"better-auth":"*"},"directories":{"example":"example"},"repository":{"type":"git","url":"git+https://github.com/amirulabu/couchdb-better-auth.git"},"author":{"name":"@amirulabu"},"license":"ISC","bugs":{"url":"https://github.com/amirulabu/couchdb-better-auth/issues"},"homepage":"https://github.com/amirulabu/couchdb-better-auth#readme","scripts":{"build":"tsc -p tsconfig.build.json","test":"vitest run","test:watch":"vitest"},"_id":"@amirulabu/couchdb-better-auth@0.1.6","_integrity":"sha512-a6cayWRtkrdmS+A54w0n4YMLYACUlMem0TIyHmBh8lWqYhJgXsjq1p3owMKYt1bOGjzRYVWTBjVLTRa36uzjmA==","_resolved":"/tmp/714c522f5f6ffe9ce654b6b5fb0532b6/amirulabu-couchdb-better-auth-0.1.6.tgz","_from":"file:amirulabu-couchdb-better-auth-0.1.6.tgz","_nodeVersion":"24.12.0","_npmVersion":"11.6.2","dist":{"integrity":"sha512-a6cayWRtkrdmS+A54w0n4YMLYACUlMem0TIyHmBh8lWqYhJgXsjq1p3owMKYt1bOGjzRYVWTBjVLTRa36uzjmA==","shasum":"8c579d999acfadd2a04344ebdf361f3e479c4a6e","tarball":"https://registry.npmjs.org/@amirulabu/couchdb-better-auth/-/couchdb-better-auth-0.1.6.tgz","fileCount":10,"unpackedSize":107899,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@amirulabu%2fcouchdb-better-auth@0.1.6","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIAxWF0CSr9nT4UfzxcwF9nDkuy/fVQbHHqpDDa68PzgVAiEAqAfBoC/Vl7xQ/rmB5xg2kyrIBpUK/uyd3ogFTCFAZlE="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:a4ddab85-3bd4-4355-8e4a-d6be69257406"}},"maintainers":[{"name":"amirulabu","email":"amirulabu@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/couchdb-better-auth_0.1.6_1766974310993_0.5837056686182702"},"_hasShrinkwrap":false}},"time":{"created":"2025-12-27T15:03:36.461Z","modified":"2025-12-29T02:11:51.532Z","0.1.0":"2025-12-27T15:03:36.694Z","0.1.1":"2025-12-27T16:16:23.373Z","0.1.5":"2025-12-27T16:34:13.922Z","0.1.6":"2025-12-29T02:11:51.135Z"},"bugs":{"url":"https://github.com/amirulabu/couchdb-better-auth/issues"},"author":{"name":"@amirulabu"},"license":"ISC","homepage":"https://github.com/amirulabu/couchdb-better-auth#readme","keywords":["better-auth","couchdb","adapter","authentication"],"repository":{"type":"git","url":"git+https://github.com/amirulabu/couchdb-better-auth.git"},"description":"Better-Auth adapter for CouchDB","maintainers":[{"name":"amirulabu","email":"amirulabu@gmail.com"}],"readme":"> **Important note:** 95% vibe coded, use at own risk! \n\n# CouchDB Better-Auth Adapter\n\nA Better-Auth database adapter for CouchDB using the [nano](https://www.npmjs.com/package/nano) package.\n\n## Installation\n\n```bash\nnpm install @amirulabu/couchdb-better-auth better-auth nano\n```\n\nOr with pnpm:\n\n```bash\npnpm add @amirulabu/couchdb-better-auth better-auth nano\n```\n\nOr with bun:\n\n```bash\nbun add @amirulabu/couchdb-better-auth better-auth nano\n```\n\n## Usage\n\n### Basic Setup\n\n```typescript\nimport { betterAuth } from \"better-auth\";\nimport { couchdbAdapter } from \"@amirulabu/couchdb-better-auth\";\n\nexport const auth = betterAuth({\n  database: couchdbAdapter({\n    url: \"http://localhost:5984\",\n    database: \"better_auth\", // Optional: defaults to \"better_auth\"\n  }),\n  // ... other Better-Auth configurations\n});\n```\n\n### Using Model Names as Database Names\n\nIf you want each model to use its own database:\n\n```typescript\nexport const auth = betterAuth({\n  database: couchdbAdapter({\n    url: \"http://localhost:5984\",\n    useModelAsDatabase: true, // Each model will use its own database\n  }),\n});\n```\n\n### With Authentication\n\nIf your CouchDB instance requires authentication:\n\n```typescript\nexport const auth = betterAuth({\n  database: couchdbAdapter({\n    url: \"http://username:password@localhost:5984\",\n    database: \"better_auth\",\n  }),\n});\n```\n\n### With Debug Logs\n\nEnable debug logging to troubleshoot issues:\n\n```typescript\nexport const auth = betterAuth({\n  database: couchdbAdapter({\n    url: \"http://localhost:5984\",\n    database: \"better_auth\",\n    debugLogs: true, // Enable all debug logs\n    // Or enable specific methods:\n    // debugLogs: {\n    //   create: true,\n    //   update: true,\n    //   findOne: true,\n    // }\n  }),\n});\n```\n\n## Configuration Options\n\n### `url` (required)\n\nThe CouchDB connection URL. Examples:\n- `\"http://localhost:5984\"`\n- `\"https://couchdb.example.com\"`\n- `\"http://username:password@localhost:5984\"`\n\n### `database` (optional)\n\nThe database name to use for all models. Defaults to `\"better_auth\"`.\n\nIf `useModelAsDatabase` is `true`, this option is ignored.\n\n**Note:** When using a shared database (default), the adapter automatically adds a `betterAuthModel` field to each document to filter models correctly.\n\n### `useModelAsDatabase` (optional)\n\nIf `true`, each model will use its own database (e.g., `user`, `session`, `account`). If `false` (default), all models will use the database specified in `database`.\n\n**Benefits of `useModelAsDatabase: true`:**\n- Better separation of concerns\n- Easier database management and backup\n- No need for model filtering fields\n\n**Benefits of shared database (default):**\n- Single database to manage\n- Easier cross-model queries (if needed)\n- Simpler setup\n\n### `debugLogs` (optional)\n\nEnable debug logging. Can be:\n- `true` - Enable all debug logs\n- `false` - Disable all debug logs (default)\n- An object with specific method flags:\n  ```typescript\n  {\n    create?: boolean;\n    update?: boolean;\n    updateMany?: boolean;\n    findOne?: boolean;\n    findMany?: boolean;\n    delete?: boolean;\n    deleteMany?: boolean;\n    count?: boolean;\n  }\n  ```\n\n## Features\n\n- ✅ Full CRUD operations (create, update, updateMany, delete, deleteMany, findOne, findMany, count)\n- ✅ Support for complex where clauses (AND, OR, operators)\n- ✅ Pagination support (limit, offset)\n- ✅ Sorting support (with automatic fallback to in-memory sorting if index is missing)\n- ✅ Automatic `_id`/`_rev` handling\n- ✅ Proper error handling (404, 409 conflicts with automatic retry)\n- ✅ TypeScript support with full type definitions\n- ✅ Works with both Bun and Node.js\n- ✅ Automatic database creation\n- ✅ Support for shared database or model-specific databases\n\n## CouchDB Requirements\n\n- CouchDB 2.0+ (for Mango query support)\n- The database(s) will be created automatically if they don't exist when first accessed\n\n## Supported Where Clause Operators\n\nThe adapter supports all Better-Auth where clause operators and converts them to CouchDB Mango selectors:\n\n- `equals` / `eq` - Equality check\n- `not` / `ne` - Not equal\n- `in` - Value in array\n- `notIn` / `not_in` - Value not in array\n- `gt` - Greater than\n- `gte` - Greater than or equal\n- `lt` - Less than\n- `lte` - Less than or equal\n- `contains` - String contains (uses regex)\n- `startsWith` / `starts_with` - String starts with (uses regex)\n- `endsWith` / `ends_with` - String ends with (uses regex)\n- `AND` - Logical AND\n- `OR` - Logical OR\n\n## Notes\n\n- CouchDB doesn't support transactions, so operations run sequentially\n- Document IDs are strings (not numeric)\n- The adapter automatically handles CouchDB's `_id` and `_rev` fields\n- When using a shared database, documents include a `betterAuthModel` field for filtering (automatically managed)\n- String operators (`contains`, `startsWith`, `endsWith`) use CouchDB regex and are case-sensitive\n- For optimal performance with sorting, ensure appropriate indexes exist in CouchDB (the adapter will fall back to in-memory sorting if needed)\n\n## Testing\n\nThe adapter uses the official Better-Auth adapter test suite. To run the tests:\n\n1. **Start a CouchDB instance** (e.g., using Docker):\n   ```bash\n   docker run -d -p 5984:5984 -e COUCHDB_USER=admin -e COUCHDB_PASSWORD=password apache/couchdb:latest\n   ```\n\n2. **Set the CouchDB URL** (optional, defaults to `http://admin:password@localhost:5984`):\n   ```bash\n   export COUCHDB_URL=http://admin:password@localhost:5984\n   ```\n\n3. **Run the tests**:\n   ```bash\n   pnpm test\n   ```\n\n   Or in watch mode:\n   ```bash\n   pnpm test:watch\n   ```\n\nThe test suite will automatically create and clean up test databases.\n\n## Examples\n\nSee the [example directory](./example/expressjs) for a complete Express.js integration example.\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## Repository\n\n- **GitHub:** [amirulabu/couchdb-better-auth](https://github.com/amirulabu/couchdb-better-auth)\n- **Issues:** [Report an issue](https://github.com/amirulabu/couchdb-better-auth/issues)\n\n## License\n\nMIT\n","readmeFilename":"README.md"}