A modern, secure pastebin service built with Rust and React. RustyBin allows you to create, view, and share text snippets with automatic syntax highlighting.
- End-to-End Encryption: Client-side AES-GCM encryption - the server never sees your paste contents
- Zero-Knowledge Architecture: Decryption keys stay in the URL fragment (#) and are never sent to the server
- Syntax Highlighting: Support for 30+ programming languages using Prism
- Auto Language Detection: Automatically detects the programming language as you type
- RESTful API: Full API for creating, retrieving, updating, and deleting pastes
- SQLite Database: Lightweight, file-based database for storing encrypted pastes
- Modern Design: Clean, dark-themed UI built with React, TypeScript, and Tailwind CSS
Enable advanced options when creating a paste:
- Burn After Read: Paste is automatically deleted after being viewed once
- Expiration: Set pastes to auto-delete after a specified time (5 min to 1 week)
- Edit Keys: Get a separate editable URL to make changes while sharing a read-only link
- Rust (latest stable)
- Node.js (v18+)
- pnpm
-
Clone the repository:
git clone https://github.com/EternityX/rustybin.git cd rustybin -
(Optional) Set up environment variables:
cp .env.example .env # Edit .env with your configuration -
Build and run the Rust backend:
cargo run
The backend server will start on http://localhost:3000 (or the port specified in your .env file).
The backend can be configured using the following environment variables:
| Variable | Description | Default |
|---|---|---|
PORT |
Server port | 3000 |
RUST_ENV |
Environment mode | development |
CORS_ALLOWED_ORIGINS |
Comma-separated list of allowed CORS origins | https://rustybin.net,http://localhost:8080,https://api.rustybin.net |
READ_RATE_LIMIT |
Read operations per minute per IP | 45 |
CREATE_RATE_LIMIT |
Create operations per minute per IP | 15 |
UPDATE_RATE_LIMIT |
Update operations per minute per IP | 15 |
DELETE_RATE_LIMIT |
Delete operations per minute per IP | 15 |
RUST_LOG |
Logging level (error, warn, info, debug, trace) | info |
Example .env file:
PORT=3000
RUST_ENV=development
CORS_ALLOWED_ORIGINS=https://yourdomain.com,http://localhost:3000
READ_RATE_LIMIT=45
CREATE_RATE_LIMIT=15
UPDATE_RATE_LIMIT=15
DELETE_RATE_LIMIT=15
RUST_LOG=infoCORS Configuration:
To allow your frontend to connect to the backend, make sure to include your frontend's URL in the CORS_ALLOWED_ORIGINS environment variable. For local development, this typically includes http://localhost:5173 (Vite's default port) or whichever port your frontend runs on.
-
Navigate to the frontend directory:
cd site -
Set up environment variables:
cp .env.example .env # Edit .env with your configurationThe
.envfile should contain:# For development - update the port to match your backend configuration VITE_API_URL=http://127.0.0.1:3000/v1 # For production # VITE_API_URL=https://yourdomain.com/v1
Note: Make sure the port in
VITE_API_URLmatches the port your Rust backend is running on (configured in the backend's.envfile) and the port has been changed invite.config.ts. -
Install dependencies:
pnpm install
-
Start the development server:
pnpm dev
The frontend development server will start on http://localhost:3000.
All endpoints are prefixed with /v1.
| Method | Endpoint | Description |
|---|---|---|
GET |
/v1/health |
Health check |
POST |
/v1/pastes |
Create a new paste |
GET |
/v1/pastes/:id |
Get a specific paste |
PUT |
/v1/pastes/:id |
Update a paste (requires edit key) |
DELETE |
/v1/pastes/:id |
Delete a paste (requires edit key) |
Create Paste (POST /v1/pastes)
{
"data": "encrypted_content",
"language": "javascript",
"burn_after_read": false,
"expires_in_minutes": null
}Note: The
datafield must contain AES-256-GCM encrypted content, not plaintext. The encryption happens client-side, and the server never sees your unencrypted data.See API_ENCRYPTION.md for detailed encryption instructions and working examples in Python and JavaScript.
Update/Delete requires an edit_key in the request body for authorization.
All endpoints include rate limit headers:
x-ratelimit-remaining: Requests remaining in the current windowx-ratelimit-reset: Seconds until the rate limit resets
Build the Rust application for production:
cargo build --releaseBuild the React application for production:
cd site
pnpm buildThe built files will be in the site/dist directory, which can be served by the Rust backend.
Please see the site/DEPLOYMENT.md to deploy on Cloudflare pages.
This project is licensed under the MIT License - see the LICENSE file for details.