Thank you for your interest in contributing to Secure Pastebin! 🎉 This document provides guidelines and information for contributors.
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/viralburst/pastebin.git cd secure-pastebin - Install dependencies:
npm install
- Start development:
npm run dev
- Node.js 18+ and npm
- Cloudflare account (free tier works)
- Wrangler CLI:
npm install -g wrangler
-
Create KV namespaces for testing:
wrangler kv namespace create PASTES_KV --preview wrangler kv namespace create ANALYTICS_KV --preview
-
Update
wrangler.tomlwith preview namespace IDs -
Run locally:
npm run dev # Visit http://localhost:8787
# Test paste creation
curl -X POST http://localhost:8787/create \
-H "Content-Type: application/json" \
-d '{"content": "test content", "expires": "1h"}'
# Test paste viewing (use ID from creation response)
curl http://localhost:8787/s/PASTE_ID
# Test web interface
open http://localhost:8787- TypeScript: Use strict typing, avoid
any - Formatting: Code is auto-formatted (no specific style guide needed)
- Comments: Add JSDoc comments for public functions
- Naming: Use descriptive variable and function names
Use clear, descriptive commit messages:
✅ Good:
- "Add download functionality for pastes"
- "Fix copy button not working in Safari"
- "Update README with deployment instructions"
❌ Avoid:
- "fix bug"
- "update stuff"
- "changes"
-
Create a feature branch:
git checkout -b feature/your-feature-name
-
Make your changes with clear, focused commits
-
Test thoroughly:
- Test the web interface manually
- Test API endpoints with curl
- Test on different browsers if UI changes
-
Update documentation if needed:
- Update README.md for new features
- Add JSDoc comments for new functions
- Update API documentation if endpoints change
-
Open a Pull Request:
- Use a clear title describing the change
- Include a description of what changed and why
- Reference any related issues
- Browser compatibility issues
- Edge cases in paste handling
- UI/UX improvements
- Performance optimizations
- Syntax highlighting with Prism.js or similar
- Search functionality for public pastes
- User accounts and paste management
- Collections/folders for organizing pastes
- Password protection for sensitive pastes
- Email notifications for paste expiry
- Mobile app or PWA features
- Bulk operations (delete multiple pastes)
- API documentation improvements
- Deployment guides for other platforms
- Video tutorials
- Translation to other languages
- Unit tests for core functions
- Integration tests for API endpoints
- Browser automation tests
- Performance benchmarks
Understanding the codebase structure will help you contribute effectively:
src/
├── core/ # Core business logic
│ ├── storage.ts # KV operations (create, read, delete pastes)
│ ├── security.ts # Content validation, XSS protection
│ ├── analytics.ts # Usage tracking and metrics
│ └── utils.ts # Helper functions, language detection
├── handlers/ # HTTP request handlers
│ ├── create.ts # POST /create - paste creation logic
│ └── view.ts # GET /s/{id} - paste viewing and deletion
├── ui/templates/ # HTML generation
│ ├── error.ts # Error page templates
│ └── view.ts # Paste view page template
├── config/ # Configuration
│ └── constants.ts # App constants and settings
└── worker.ts # Main entry point, request routing
- KV Storage: Cloudflare's key-value store with TTL for automatic cleanup
- Progressive Enhancement: Features work without JavaScript, enhanced with JS
- Security First: All user input is escaped, content is validated
- Edge Computing: Runs on Cloudflare's global network for speed
-
Add route in
src/worker.ts:if (url.pathname === '/api/new-endpoint' && request.method === 'GET') { return handleNewEndpoint(request, env); }
-
Create handler function:
async function handleNewEndpoint(request: Request, env: Env): Promise<Response> { // Implementation here return Response.json({ success: true, data: result }); }
-
Test the endpoint:
curl http://localhost:8787/api/new-endpoint
- Update templates in
src/ui/templates/ - Test in browser with
npm run dev - Ensure progressive enhancement (works without JS)
-
Add to
src/config/constants.ts:export const NEW_SETTING = env.NEW_SETTING || 'default-value';
-
Document in
wrangler.toml:[vars] NEW_SETTING = "production-value"
-
Update README with configuration docs
- KV namespace errors: Ensure preview namespaces are created and configured
- CORS issues: Check that your local server is running on the expected port
- TypeScript errors: Run
npm run type-checkto see all type issues
- Check Wrangler logs:
wrangler tailto see real-time logs - Test with curl: Isolate API issues from UI issues
- Check KV storage: Use Wrangler CLI to inspect stored data
- HTML escaping: Always escape user content to prevent XSS
- Rate limiting: Test with multiple requests to ensure limits work
- TTL behavior: KV TTL is approximate, not exact
- JavaScript optional: Ensure features work without JS enabled
- Bundle size: Keep the worker small for fast cold starts
- KV operations: Minimize KV reads/writes for better performance
- HTML minification: Compress responses to reduce bandwidth
- Caching: Use appropriate cache headers for static content
- Input validation: Validate all user input on the server side
- XSS prevention: HTML escape all user content
- Rate limiting: Implement appropriate rate limits
- Content scanning: Check for suspicious patterns in pastes
- No sensitive data: Don't log sensitive information
- Be respectful and constructive in discussions
- Help others by answering questions and reviewing PRs
- Share knowledge through documentation and examples
- Report issues clearly with reproduction steps
- Credit contributors when building on their work
- GitHub Issues: For bugs and feature requests
- GitHub Discussions: For questions and general discussion
- Code Comments: Check inline documentation in the codebase
- README: Comprehensive setup and usage documentation
Contributors will be:
- Listed in README acknowledgments section
- Credited in release notes for significant contributions
- Mentioned in commit messages when building on their work
Thank you for contributing to Secure Pastebin! 🚀