Skip to content

sigman78/cf-haste-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

263 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

 _   _           _
| | | | __ _ ___| |_ ___
| |_| |/ _` / __| __/ _ \
|  _  | (_| \__ \ ||  __/
|_| |_|\__,_|___/\__\___|

Cloudflare Workers Edition

Original haste-server by John Crepezzi, modernized for Cloudflare's edge network.

A pastebin that runs on Cloudflare Workers. Demo

Why this fork

The original runs on Node.js + Redis. This version drops both: Workers replace the server, D1 (SQLite at the edge) replaces Redis. No cold starts, global distribution, fits in the free tier for personal use.

Rewritten in TypeScript with Vite, no jQuery.

Quick start

npm install
npm run db:migrate:local
npm run dev          # http://localhost:8787

Deploy

npx wrangler d1 create haste-db   # copy the database_id into wrangler.toml
npm run db:migrate:remote
npm run deploy

Your instance will be live at https://haste.YOUR-SUBDOMAIN.workers.dev.

Config

Edit wrangler.toml vars:

Variable Default Description
MAX_PASTE_SIZE 400000 Max paste size in bytes
KEY_LENGTH 10 Length of paste IDs
DEFAULT_EXPIRE_DAYS 30 Days until expiration

API

curl -X POST https://your-worker.dev/documents -H "Content-Type: text/plain" -d "code here"
curl https://your-worker.dev/documents/KEY
curl https://your-worker.dev/raw/KEY

Shortcuts

Action Shortcut
Save Ctrl+Enter / Ctrl+S
New Alt+Shift+N
Duplicate Alt+Shift+D
Share on X Alt+Shift+X

Tests

npm test

License

MIT. Original Haste by John Crepezzi.

About

Modern adaptation of hastebin server for cloudflare deployment

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Contributors