About
Pastebnn is a simple pastebin server built with Rust and Svelte. Pastes can be given a custom URL, set to expire after a period of time, or burned after they are read once.

Design
Browser ──> Axum ──┬── /api/paste ──> Storer ──┬── In-Memory
│ └── Redis
└── /* ──> SvelteKit static build
Pastebnn runs as a single Rust binary built with Axum and Tokio. The same server handles the JSON API and serves the static SvelteKit and Tailwind frontend, so the whole application ships as one container.
Storage sits behind a Storer trait with two implementations, chosen at startup. The in-memory store keeps pastes in a HashMap and a background task periodically clears out expired pastes. The Redis store writes with SET NX EX, where NX refuses to overwrite an existing key and EX lets Redis expire pastes natively.
Burn on read pastes should only ever be seen once, even if two people open the link at the same time. Only the reader whose DEL actually removes the key gets the paste back, everyone else gets a 404. Each paste also returns a delete token on creation, which is never shown again.
API
Create a paste:
curl --header "Content-Type: application/json" \
--request POST \
--data '{"text": "hello world", "seconds_until_expire": 600}' \
https://bin.evanslack.dev/api/paste
POST /api/pastecreates a paste and returns it with adelete_tokenGET /api/paste/:keyreturns a pasteDELETE /api/paste/:keydeletes a paste with theX-Delete-Tokenheader
Deploying
There are prebuilt docker images at evanofslack/pastebnn:latest
services:
pastebnn:
image: evanofslack/pastebnn:latest
ports:
- 8080:8080
Pastes are kept in memory by default. To persist pastes with Redis, use the docker-compose.yml in the repo.
