Development Guide
Welcome to CloudPaste development! This guide will help you set up a development environment and understand the project structure.
Development Environment Requirements
System Requirements
- Node.js: Version 18 or higher
- npm: Version 8 or higher (or pnpm, yarn)
- Git: Version control tool
Recommended Tools
- VS Code: Code editor
- Wrangler CLI: Cloudflare Workers development tool
- Docker: Containerized development (optional)
Quick Start
1. Clone Project
bash
# Clone repository
git clone https://github.com/ling-drag0n/CloudPaste.git
cd CloudPaste2. Install Dependencies
bash
# Install backend dependencies
cd backend
npm install
# Install frontend dependencies
cd frontend
npm install3. Configure Environment
Backend Configuration
Create backend/wrangler.toml file:
toml
name = "cloudpaste-backend-dev"
main = "worker.js"
compatibility_date = "2024-01-01"
[env.development]
vars = { NODE_ENV = "development" }
[[env.development.d1_databases]]
binding = "DB"
database_name = "cloudpaste-db-dev"
database_id = "your-database-id"
[env.development.vars]
ENCRYPTION_SECRET = "your-development-secret"Frontend Configuration
Create frontend/.env.development file:
bash
VITE_BACKEND_URL=http://localhost:8787
VITE_APP_ENV=development
VITE_ENABLE_DEVTOOLS=true4. Initialize Database
bash
# Create development database
cd backend
npx wrangler d1 create cloudpaste-db-dev
# Initialize database structure
npx wrangler d1 execute cloudpaste-db-dev --file=./schema.sql5. Start Development Server
bash
# Start backend development server
cd backend
npm run dev
# Start frontend development server in new terminal
cd frontend
npm run devNow you can access:
- Frontend: http://localhost:5173
- Backend: http://localhost:8787
Custom Docker Build
If you want to customize Docker images or perform development debugging, you can manually build following these steps:
Build Backend Image
bash# Execute in project root directory docker build -t cloudpaste-backend:custom -f docker/backend/Dockerfile . # Run custom built image docker run -d --name cloudpaste-backend \ -p 8787:8787 \ -v $(pwd)/sql_data:/data \ -e ENCRYPTION_SECRET=development-test-key \ cloudpaste-backend:customBuild Frontend Image
bash# Execute in project root directory docker build -t cloudpaste-frontend:custom -f docker/frontend/Dockerfile . # Run custom built image docker run -d --name cloudpaste-frontend \ -p 80:80 \ -e BACKEND_URL=http://localhost:8787 \ cloudpaste-frontend:customDevelopment Environment Docker Compose
Create
docker-compose.dev.ymlfile:yamlversion: "3.8" services: frontend: build: context: . dockerfile: docker/frontend/Dockerfile environment: - BACKEND_URL=http://backend:8787 ports: - "80:80" depends_on: - backend backend: build: context: . dockerfile: docker/backend/Dockerfile environment: - NODE_ENV=development - RUNTIME_ENV=docker - PORT=8787 - ENCRYPTION_SECRET=dev_secret_key volumes: - ./sql_data:/data ports: - "8787:8787"Start development environment:
bashdocker-compose -f docker-compose.yml up --build
Development Workflow
1. Create Feature Branch
bash
# Create new branch from main
git checkout main
git pull origin main
git checkout -b feature/your-feature-name2. Commit Code
bash
# Add files
git add .
# Commit code (use standard commit messages)
git commit -m "feat: add new feature"
# Push to remote branch
git push origin feature/your-feature-name4. Create Pull Request
- Create Pull Request on GitHub
- Fill in detailed description
- Wait for code review
- Modify code based on feedback
Code Standards
Commit Message Standards
Use Conventional Commits standard:
feat: New featurefix: Bug fixdocs: Documentation updatestyle: Code formattingrefactor: Code refactoringtest: Test relatedchore: Build tools or auxiliary tool changes
Examples:
feat: add file upload progress indicator
fix: resolve authentication token expiration issue
docs: update API documentationDebugging Tips
Frontend Debugging
- Vue DevTools: Install Vue.js devtools browser extension
- Console Logs: Use
console.logfor debugging - Network Panel: Check API requests and responses
Backend Debugging
- Wrangler Logs: Use
wrangler tailto view real-time logs - Local Debugging: Debug Worker code in local environment
- D1 Queries: Use
wrangler d1 executeto query database
Contribution Guide
Report Bugs
- Search existing Issues to confirm the problem hasn't been reported
- Create new Issue with detailed information:
- Problem description
- Reproduction steps
- Expected behavior
- Actual behavior
- Environment information
Feature Requests
- Discuss new features in GitHub Discussions
- Create Feature Request Issue
- Provide detailed feature description and use cases
Code Contributions
- Fork project repository
- Create feature branch
- Implement feature and add tests
- Ensure all tests pass
- Submit Pull Request
Getting Help
- GitHub Issues: Report bugs and feature requests
- GitHub Discussions: Community discussions
