TypeScript · 2023

Pastebin R2

A pastebin on Cloudflare Workers in TypeScript with Hono, storing objects in R2 behind a small REST API — create, update, list, info, delete — with syntax-highlighted and plain-text views, and pastes that expire on their own.

View sourceOpen pastebin

Pastebin R2 editor and command-line usage

The problem

Provide a small paste service whose objects expire predictably, without introducing a separate application server or database for the paste bodies.

Architecture

  • Hono routes the API and browser interface in a Cloudflare Worker.
  • R2 stores paste bodies and their TTL in custom metadata.
  • Reads enforce expiry immediately while an hourly cron sweeps what is left.

Highlights

  • Syntax-highlighted and plain-text views
  • Configurable lifetimes capped at 48 hours
  • A Nix flake for dev and build, and a live instance at paste.codebam.ca

Technology

TypeScript · cloudflare · r2 · hono

← All selected work

Need something like this?

Let’s scope it.

Custom websites and Telegram bots, scoped per project and quoted by email.

See servicesGet in touch