A minimalist pastebin service built with Node.js and Express that uses content hashing for unique paste identification.
Topics: nodejs express pastebin file-storage content-hashing sha256 deduplication web-app minimal javascript backend url-shortener
- Content-based hashing - SHA-256 hash of content as paste ID
- Short URLs - 8-character shortened URLs for easy sharing
- Automatic deduplication - Identical content shares same URL
- Raw text view - Access raw content at
/raw/:id - File-based storage - Stores pastes as text files locally
- Clean interface - Minimal UI focused on functionality
- XSS protection - Basic HTML escaping for security
-
Clone the project
-
Install dependencies
yarn install- Start the server
node index.js- Visit
http://localhost:3000 - Enter your content in the textarea
- Click "Create Paste"
- Get both full and short URLs for your paste
- HTML view:
/paste/:id- Formatted display - Short URL:
/s/:shortId- Redirects to full paste (8 chars) - Raw view:
/raw/:id- Plain text content
GET /- Home page with paste formPOST /paste- Create new pasteGET /paste/:id- View paste in HTML formatGET /s/:shortId- Short URL redirect to full pasteGET /raw/:id- View raw paste content
- Content Hashing: Uses SHA-256 to generate unique IDs from content
- Deduplication: Same content always gets same hash/URL
- File Storage: Saves pastes as
{hash}.txtin./pastes/directory
pastebin/
├── index.js # Main application
├── package.json # Dependencies and config
├── pastes/ # Auto-created directory for paste files
└── README.md # This file
- Port: Default 3000 (change
PORTvariable in index.js) - Storage: Files stored in
./pastes/directory - Hash Algorithm: SHA-256 (64 character hex strings)
- Basic XSS protection with HTML escaping
- No authentication or rate limiting
- Files stored locally (not suitable for production without modifications)
- Consider adding HTTPS or use behind proxy, rate limiting, and proper security headers for production use
MIT