Skip to content

ajmeese7/reading-log

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reading Log

Cloudflare Worker that stores a curated reading list in KV and exposes JSON, Markdown, and RSS endpoints.

Install / Prereqs

  • Cloudflare account
  • Node.js 18+
  • Wrangler CLI

Install Wrangler:

npm install -g wrangler

Login:

wrangler login

Endpoints

GET /

Minimal HTML reading log page (use for your subdomain).

Optional query params:

  • limit (default 5, max 20)

GET /reading

Returns JSON list of items (newest first).

Query params:

  • limit (default 5, max 20)

GET /reading/markdown

Returns a Markdown list for README embedding.

Query params:

  • limit (default 5, max 20)

GET /reading/rss

Returns an RSS feed.

Query params:

  • limit (default 5, max 20)

POST /reading/add

Adds an item. Requires auth.

Headers:

  • Authorization: Bearer $READING_TOKEN or X-Reading-Token: $READING_TOKEN

JSON body:

{
  "title": "Article title",
  "url": "https://example.com/article",
  "added_at": "Optional ISO timestamp"
}

DELETE /reading/remove

Removes an item by URL. Requires auth.

Headers:

  • Authorization: Bearer $READING_TOKEN or X-Reading-Token: $READING_TOKEN

JSON body:

{
  "url": "https://example.com/article"
}

Returns 404 if no item matches the given URL.

Truncation Rules (Markdown list)

  • If title length is 85+, truncate to 80 characters and append .
  • If title length is 84 or less, display the full title.

Setup

  1. Create a KV namespace and bind it in wrangler.toml as READING_KV.

    wrangler kv namespace create READING_KV
    wrangler kv namespace create READING_KV --preview
  2. Add the KV IDs to wrangler.toml.

  3. Optionally store your token locally in .env (do not commit it):

    cp .env.example .env
    # edit .env and set READING_TOKEN
  4. Set the write token in Cloudflare:

    wrangler secret put READING_TOKEN

    Hint: Use a long random string, e.g. openssl rand -hex 32.

    You will be prompted to create a Cloudflare Worker if one does not exist yet. Select "yes" to create one.

  5. Optional metadata (set in wrangler.toml under [vars] or via secrets):

    wrangler secret put READING_SITE_TITLE
    wrangler secret put READING_SITE_URL
    wrangler secret put READING_MORE_URL
  6. Deploy:

    wrangler deploy

Example: add an item

curl -X POST https://YOUR_WORKER_URL/reading/add \
  -H "Authorization: Bearer $READING_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"title":"Example title","url":"https://example.com"}'

Example: remove an item

curl -X DELETE https://YOUR_WORKER_URL/reading/remove \
  -H "Authorization: Bearer $READING_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://example.com/article"}'

README Integration (optional)

If your GitHub README contains:

<!-- READING-LOG:START -->
...
<!-- READING-LOG:END -->

You can populate it with the Markdown endpoint:

https://YOUR_WORKER_URL/reading/markdown?limit=5

Subdomain

Point your reading.<domain> to the Worker and it will serve the HTML page at /.

Recommended (Worker Route):

  1. DNS record: create a CNAME record for reading that points to your root domain (@) or any existing hostname in your zone. Make sure it’s proxied (orange cloud).
  2. Worker route: in Cloudflare → Workers & Pages → your worker → Triggers, add a route:
    reading.yourdomain.com/*
    

Alternative (Custom Domain): If your Cloudflare plan supports Worker custom domains, add reading.yourdomain.com in the worker’s Settings → Domains and Cloudflare will create the DNS record automatically.

Your RSS remains available at:

https://reading.yourdomain.com/reading/rss

About

Log articles consumed to an RSS feed via Cloudflare Workers.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors