- Overview
- Key Features
- Screenshots
- Technical Stack
- Security & Privacy
- Getting Started
- Development
- API Documentation
- Rate Limiting
- Contributing
- License
BePasted is a modern, privacy-focused text and code sharing service built with a "less is more" philosophy. Unlike many alternatives, BePasted requires no account creation while still providing powerful features. We prioritize user privacy and content security without compromising on functionality.
- Multi-tab Support - Create up to 10 tabs per paste for organizing related content
- Code Highlighting - Automatic syntax detection with theme support
- Line Numbers & Word Counter - For better readability and reference
- Privacy Options:
- Password-protected pastes with bcrypt encryption
- Customizable expiration (time-based or view-based)
- Burn-after-reading functionality
- Raw Text Access - Direct access to paste content for public, single-tab pastes
- Responsive Design - Works seamlessly on desktop and mobile devices
- No Registration Required - Create and share pastes instantly
Backend | Frontend | Security |
---|---|---|
|
|
BePasted implements numerous security and privacy features:
- β IP anonymization with cryptographic hashing
- β Strict data retention policies (configurable, defaults: 30 days for active pastes, 90 days for archived)
- β No tracking cookies or user profiling
- β Privacy-focused analytics with SimpleAnalytics
- β Content scanning for malicious code and sensitive data
- β CSRF protection against cross-site request forgery
- β Strict input validation and content sanitization
- β Secure password handling with bcrypt
- β Rate limiting to prevent abuse
- β Database connection pooling with security timeouts
- β Comprehensive error handling and secure logging
- β Cross-Origin Resource Sharing (CORS) protection
- β BetterStack for centralized, privacy-focused logging
- Node.js 18 or higher
- MongoDB 4.4 or higher
- A Cloudflare account for Turnstile integration
-
Clone the repository
git clone https://github.com/rimunace/bepasted.git cd bepasted
-
Install dependencies
npm install
-
Configure environment
cp .env.example .env
-
Generate security keys
On Linux/macOS/WSL:
# Generate random values for IP_HASH_SALT and CSRF_SECRET openssl rand -hex 32 # Use this for IP_HASH_SALT openssl rand -hex 32 # Use this for CSRF_SECRET
On Windows:
# Run the included PowerShell script .\pwsh-scripts\generate-secrets.ps1
-
Update the
.env
file with:- Your MongoDB connection string
- Cloudflare Turnstile credentials
- Generated security keys
- BetterStack token (if using)
See the
.env.example
file for all available configuration options. BePasted uses a centralized configuration system that validates all settings, provides sensible defaults, and gives helpful error messages. -
Start the server
npm start
# Build the Docker image
docker build -t bepasted .
# Run the container
docker run -p 3000:3000 --env-file .env bepasted
Start the development server with auto-reload:
npm run dev
Run tests:
npm test
Build for production:
npm run build
Start the production server:
npm start
BePasted uses a centralized configuration system located in src/utils/config/config.js
that provides:
- Schema-based validation with detailed error messages
- Type conversion (string to number, boolean, arrays)
- Sensible defaults for optional parameters
- Environment-specific validation (stricter in production)
- Security awareness by marking sensitive values
Benefits for developers:
- All configuration is accessed through a single
config
object - Configuration errors are detected early at startup
- Types are automatically converted (no need for
parseInt
etc.) - The schema serves as documentation for environment variables
- Strong security with validation of security-critical parameters
To add a new configuration parameter:
- Add it to the
configSchema
object insrc/utils/config/config.js
- Define its type, validation rules, default value, etc.
- Import and use from
config
in your modules:import config from '../utils/config/config.js'
BePasted implements configurable data retention policies:
DATA_RETENTION_DAYS
: Controls how long active pastes are retained (default: 30 days)ARCHIVE_RETENTION_DAYS
: Controls how long expired pastes are archived before deletion (default: 90 days)
These values can be adjusted in your .env
file to meet your specific requirements or compliance needs.
The src/utils
directory is organized into categories for better code organization and maintainability:
config/
- Configuration-related utilitieshttp/
- HTTP request/response handling utilitiessecurity/
- Security-related utilities (IP handling, rate limiting, etc.)logging/
- Logging and error handling utilitiesmaintenance/
- System maintenance and cleanup utilities
For details on the directory structure and import guidelines, see Utils Directory Structure.
BePasted offers a simple API for programmatic access. This documentation is intended for advanced users who need to integrate with BePasted programmatically.
POST /paste
Content-Type: application/json
Request Body:
{
"tabs": [
{
"id": 0,
"name": "main.js",
"content": "console.log('Hello, world!');"
}
],
"isPrivate": false,
"allowRaw": true,
"expiry": {
"value": 7,
"unit": "days"
},
"token": "TURNSTILE_TOKEN"
}
Required Fields:
tabs
: Array of tab objects (max 10)- Each tab must have
id
,name
, andcontent
- Content size limit: 2MB per tab
- Each tab must have
token
: Cloudflare Turnstile token for bot protection
Optional Fields:
isPrivate
: Boolean (default: false)password
: Required if isPrivate is true (1-32 characters)allowRaw
: Boolean (default: false, only works for public, single-tab pastes)expiry
: Object withvalue
(minimum 5) andunit
(seconds, minutes, hours, days)burnCount
: Number of views after which paste expires (1-10000000000)
Response:
{
"id": "a1b2c3d4"
}
Status Codes:
200
: Success400
: Invalid input413
: Request entity too large429
: Rate limit exceeded (10 pastes per minute per IP)
GET /api/paste/{id}
Parameters:
id
: Paste ID (path parameter)password
: For private pastes (query parameter)
Response:
{
"tabs": [...],
"isPrivate": false,
"allowRaw": true,
"expiry": {
"value": 7,
"unit": "days",
"expiresAt": "2023-12-31T23:59:59Z"
},
"burnCount": 10,
"currentViews": 3,
"createdAt": "2023-12-24T12:00:00Z"
}
Status Codes:
200
: Success401
: Password required or invalid404
: Paste not found410
: Paste has expired429
: Too many password attempts
GET /api/paste/{id}/raw
Parameters:
id
: Paste ID (path parameter)
Response: Raw text content with Content-Type: text/plain
Status Codes:
200
: Success403
: Raw access not allowed404
: Paste not found410
: Paste has expired
POST /paste/{id}/verify-password
Content-Type: application/json
Request Body:
{
"password": "your_password"
}
Response:
{
"success": true
}
Status Codes:
200
: Success400
: Bad request401
: Invalid password404
: Paste not found410
: Paste has expired429
: Too many password attempts (6 attempts per minute per paste per IP)
POST /paste/{id}/report
Content-Type: application/json
Request Body:
{
"reason": "Contains malicious code"
}
Response:
{
"success": true,
"message": "Paste reported successfully"
}
Status Codes:
200
: Success400
: Invalid input404
: Paste not found
Rate Limiting: 3 reports per minute per IP
For a complete API reference, see the OpenAPI specification files in the repository:
To prevent abuse while ensuring fair usage:
Action | Limit |
---|---|
Paste Creation | 10 pastes per minute per IP |
Private Paste Access | 6 password attempts per minute per IP |
API Requests | 100 requests per minute per IP |
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create a feature branch
git checkout -b feature/amazing-feature
- Commit your changes
git commit -m 'Add some amazing feature'
- Push to the branch
git push origin feature/amazing-feature
- Open a Pull Request
Please make sure your code follows the existing style and includes appropriate tests.
Please be respectful and inclusive when contributing to this project. We value the input of everyone regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality.
BePasted is licensed under the ISC License.
Made with β€οΈ by Respy.Tech