Skip to content

Latest commit

 

History

History
101 lines (70 loc) · 2.64 KB

README.md

File metadata and controls

101 lines (70 loc) · 2.64 KB

TusFlow API

A high-performance, scalable implementation of the TUS resumable upload protocol using Cloudflare Workers. This API allows for reliable file uploads with support for resumption, chunking, and progress tracking.

Features

  • Full TUS protocol v1.0.0 implementation
  • Chunked upload support with dynamic chunk sizing
  • Upload resumption and progress tracking
  • AWS S3/R2 storage backend
  • Redis-based state management
  • Rate limiting and file validation
  • Health monitoring and metrics
  • CORS and security headers
  • Authentication middleware

Prerequisites

  • Node.js 16+ or Bun 1.0+
  • AWS S3 or Cloudflare R2 bucket
  • Upstash Redis instance
  • Cloudflare Workers account

Installation

# Using bun (recommended)
bun install

# Using npm
npm install

Configuration

  1. Configure your wrangler.toml with appropriate values

  2. Set up your secrets using wrangler:

wrangler secret put AWS_ACCESS_KEY_ID
wrangler secret put AWS_SECRET_ACCESS_KEY
wrangler secret put UPSTASH_REDIS_REST_URL
wrangler secret put UPSTASH_REDIS_REST_TOKEN
wrangler secret put INTERNAL_API_KEY
  1. Optional: Configure additional settings in src/config

Development

# Start development server
bun run dev


# Deploy to Cloudflare Workers
bun run deploy

API Documentation

Endpoints

  • POST /files: Initialize upload
  • PATCH /files/{uploadId}: Upload file chunk
  • HEAD /files/{uploadId}: Get upload status
  • GET /files/{uploadId}/progress: Get upload progress
  • DELETE /files/{uploadId}: Cancel upload
  • GET /health: Check API health

For detailed API documentation, see API.md

Security

  • All endpoints (except /health) require authentication
  • File validation for type and size
  • Rate limiting per endpoint
  • Secure headers and CORS configuration
  • Environment-based configuration
  • Secrets management through Cloudflare Workers

Contributing

Contributions are welcome! Please read our Contributing Guidelines for details.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

Formatted with Biome Linted with Biome Checked with Biome