{"id":50642371,"url":"https://github.com/rcarmo/bun-opds-server","last_synced_at":"2026-06-07T09:30:50.524Z","repository":{"id":348947798,"uuid":"1200464317","full_name":"rcarmo/bun-opds-server","owner":"rcarmo","description":"Read-only multi-library OPDS server for Calibre, built for the XteInk X4 and CrossPoint Reader.","archived":false,"fork":false,"pushed_at":"2026-04-08T06:31:43.000Z","size":92,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-23T20:28:48.034Z","etag":null,"topics":["bun","calibre","cbr","cbz","crosspoint-reader","ebook","epub","ereader","opds","pdf","xteink-x4"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rcarmo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-03T12:52:04.000Z","updated_at":"2026-04-15T21:59:44.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/rcarmo/bun-opds-server","commit_stats":null,"previous_names":["rcarmo/bun-opds-server"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/rcarmo/bun-opds-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcarmo%2Fbun-opds-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcarmo%2Fbun-opds-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcarmo%2Fbun-opds-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcarmo%2Fbun-opds-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rcarmo","download_url":"https://codeload.github.com/rcarmo/bun-opds-server/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcarmo%2Fbun-opds-server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34016491,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-07T02:00:07.652Z","response_time":124,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bun","calibre","cbr","cbz","crosspoint-reader","ebook","epub","ereader","opds","pdf","xteink-x4"],"created_at":"2026-06-07T09:30:49.709Z","updated_at":"2026-06-07T09:30:50.520Z","avatar_url":"https://github.com/rcarmo.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bun-opds-server\n\n\u003e A lightweight read-only OPDS server that merges multiple Calibre libraries into a single catalog, with EPUB, PDF, CBZ, and CBR downloads for devices like the **XteInk X4** running **CrossPoint Reader**.\n\nA small read-only OPDS server for **multiple Calibre libraries under one filesystem tree**.\n\nIt scans for `metadata.db` files, merges supported book formats across libraries, deduplicates by title, and exposes simple OPDS feeds for ebook readers.\n\nIt is intended to work especially well with [CrossPoint Reader](https://github.com/crosspoint-reader/crosspoint-reader) on the XteInk X4 and similar eink devices that can consume OPDS catalogs and direct downloads.\n\n## Current MVP\n\n- recursively discovers Calibre libraries under `CALIBRE_ROOT`\n- reads `metadata.db` in read-only mode\n- merges all books with available **EPUB**, **PDF**, **CBZ**, and/or **CBR** files\n- deduplicates entries by normalized book title, keeping the newest copy\n- exposes OPDS feeds for:\n  - recent additions (capped for ereader compatibility)\n  - recently updated (capped for ereader compatibility)\n  - per-library views\n  - search results (capped for ereader compatibility)\n- exposes lightweight HTML browse pages with:\n  - constrained cover display\n  - minimal metadata (series, tags, updated/published dates, short description)\n  - direct EPUB/PDF/CBZ/CBR download links when available\n- supports pagination for browse/feed views\n- keeps HTML browse/search views unbounded by the feed cap so full libraries remain browseable\n- supports scored search ordering across title, authors, series, tags, and library\n- serves direct EPUB/PDF/CBZ/CBR downloads when present\n- optionally serves cover images\n- supports optional HTTP basic auth\n- includes a minimal KOReader progress sync API with SQLite-backed state\n\n## Why this exists\n\nThis is aimed at setups where:\n\n- there are **multiple separate Calibre libraries**\n- they live under one parent tree\n- a reader should be able to point at **one OPDS endpoint**\n- the main use case is: *show me the most recent books and let me download them in whatever format is available*\n\n## Endpoints\n\n### JSON / service\n- `/health`\n- `/libraries`\n\n### OPDS\n- `/opds`\n- `/opds/recent`\n- `/opds/updated`\n- `/opds/library/:librarySlug`\n- `/opds/search?q=dune`\n\n### HTML browse views\n- `/`\n- `/browse/recent`\n- `/browse/updated`\n- `/library/:librarySlug`\n- `/search?q=dune`\n\n### Asset / download\n- `/download/:librarySlug/:bookId/epub`\n- `/download/:librarySlug/:bookId/pdf`\n- `/download/:librarySlug/:bookId/cbz`\n- `/download/:librarySlug/:bookId/cbr`\n- `/cover/:librarySlug/:bookId`\n\n### KOReader sync\n- `POST /users/create`\n- `GET /users/auth`\n- `PUT /syncs/progress`\n- `GET /syncs/progress/:document`\n\nSearch results are ranked primarily by title matches, then by author/series/tag/library matches, with recency as a tiebreaker. OPDS feeds stay capped to the configured feed limit; HTML browse and search views can paginate through the full result set.\n\n## Quick start\n\n```bash\ncd /workspace/projects/bun-opds-server\ncp .env.example .env\nbun run index.ts\n```\n\nOr with inline variables:\n\n```bash\ncd /workspace/projects/bun-opds-server\nCALIBRE_ROOT=/volume1/books \\\nBASE_URL=http://localhost:8787 \\\nbun run index.ts\n```\n\n## Environment\n\n| Variable | Default | Purpose |\n|---|---|---|\n| `CALIBRE_ROOT` | `/volume1/books` | Root directory to scan for Calibre libraries |\n| `HOST` | `0.0.0.0` | Bind host |\n| `PORT` | `8787` | Bind port |\n| `BASE_URL` | `http://localhost:$PORT` | Public base URL used in OPDS links |\n| `FEED_LIMIT` | `100` | Max entries in recent/updated feeds |\n| `REFRESH_MS` | `600000` | Background refresh interval |\n| `BASIC_AUTH_USER` | unset | Optional basic auth username |\n| `BASIC_AUTH_PASS` | unset | Optional basic auth password |\n| `KOSYNC_DB_PATH` | `$CALIBRE_ROOT/koreader.db` | SQLite path for KOReader sync state |\n\n## Development\n\n```bash\nbun run index.ts --help\nbun run --watch index.ts\n```\n\n## Docker image\n\nTagged releases publish a container image to:\n\n- `ghcr.io/rcarmo/bun-opds-server`\n\n### Run with Docker\n\n```bash\ndocker run --rm -p 8787:8787 \\\n  -e CALIBRE_ROOT=/books \\\n  -e BASE_URL=http://localhost:8787 \\\n  -v /path/to/books:/books:ro \\\n  ghcr.io/rcarmo/bun-opds-server:latest\n```\n\n### Run with Docker Compose\n\nA sample Compose file is included as:\n\n- `docker-compose.yml`\n\nIt supports `PUID` / `PGID` via Compose user mapping so the container can read host-mounted libraries as the expected user and group.\n\nExample `.env` values:\n\n```env\nPUID=1000\nPGID=1000\n```\n\n```bash\ndocker compose up -d\n```\n\n## Releases\n\nA GitHub Actions workflow builds and publishes the container image on every pushed tag matching `v*`.\n\nFor semver tags like `v0.1.0`, the workflow publishes tags such as:\n\n- `ghcr.io/rcarmo/bun-opds-server:0.1.0`\n- `ghcr.io/rcarmo/bun-opds-server:0.1`\n- `ghcr.io/rcarmo/bun-opds-server:0`\n- `ghcr.io/rcarmo/bun-opds-server:latest`\n\nExample:\n\n```bash\ngit tag v0.2.3\ngit push origin v0.2.3\n```\n\n## KOReader sync\n\nThis project now includes a minimal compatible implementation of KOReader's progress sync API.\n\n### What it does\n\n- stores reading progress in a SQLite database\n- defaults to keeping that database at the top of the Calibre tree as `koreader.db`\n- auto-creates users on first successful auth/sync interaction\n- stores only per-user document progress state, not book files or filenames\n\n### Auth model\n\nKOReader sends auth headers:\n\n- `x-auth-user`\n- `x-auth-key`\n\nThe sync endpoints use those directly. If a user does not already exist, the first successful request creates it. Later requests must present the same key.\n\n### Stored progress model\n\nPer synced document, the server stores:\n\n- `document` (32-character MD5 document identifier from KOReader)\n- `progress`\n- `percentage`\n- `device`\n- `device_id`\n- update timestamp\n\n### Scope\n\nThis is intentionally limited to **progress sync**. It does not attempt to extend OPDS itself or add broader account management.\n\n### KOReader device setup example\n\nOn the KOReader device, set the custom sync server URL to your server base URL, for example:\n\n- `https://books.example.net`\n- or `http://192.168.1.50:8787` on a trusted LAN\n\nThe KOReader sync plugin will talk to these endpoints on that same base URL:\n\n- `GET /users/auth`\n- `PUT /syncs/progress`\n- `GET /syncs/progress/:document`\n\nExample self-hosted setup flow:\n\n1. Open **Progress sync** settings in KOReader.\n2. Enter the custom server base URL, e.g. `http://192.168.1.50:8787`.\n3. Choose a username.\n4. Choose a password/key.\n5. Let KOReader authenticate or sync once.\n\nBecause this server auto-creates users on first successful use, there is no separate admin-side provisioning step.\n\n## Design notes\n\n- intentionally **read-only**\n- currently assumes cover images live at `cover.jpg` inside each Calibre book directory\n- cover display in HTML views is size-constrained with CSS; server-side physical resizing is still a future improvement\n- currently deduplicates by normalized title and keeps the newest matching item\n- search uses simple weighted scoring across title, authors, series, tags, and library name\n- currently exposes a **minimal OPDS 1.x-style feed** aimed at ebook readers, with EPUB/PDF/CBZ/CBR acquisition links when present\n\n## Next likely steps\n\n- better cover detection\n- server-side thumbnail generation / resizing\n- deployment examples (Compose / reverse proxy)\n- additional OPDS compatibility testing across readers and eink devices\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frcarmo%2Fbun-opds-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frcarmo%2Fbun-opds-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frcarmo%2Fbun-opds-server/lists"}