|
1 | | -# Jump - Ephemeral Share Service |
| 1 | +# Jump Service |
2 | 2 |
|
3 | | -[](https://opensource.org/licenses/MIT) |
4 | | -[](https://github.com/rust-lang/rust/actions) |
5 | | - |
6 | | - |
7 | | -Jump is a secure and efficient ephemeral sharing service built with Rust. It allows users to share content that automatically expires after a set duration, ensuring data privacy and security. |
| 3 | +A high-performance, Redis-backed temporary payload storage service with rate limiting. |
8 | 4 |
|
9 | 5 | ## Features |
10 | 6 |
|
11 | | -- **Ephemeral Sharing**: Content automatically expires after a configurable duration |
12 | | -- **Secure**: Content is encrypted and only accessible via unique hash IDs |
13 | | -- **Rate Limited**: Built-in protection against abuse |
14 | | -- **Type Safe**: Strict MIME type validation for content |
15 | | -- **Fast**: Built with Rust for optimal performance |
16 | | -- **Simple API**: RESTful API for easy integration |
| 7 | +- Create, retrieve, and delete temporary payloads |
| 8 | +- Built-in rate limiting |
| 9 | +- Automatic payload expiration |
| 10 | +- High performance with Redis backend |
| 11 | +- Comprehensive logging |
| 12 | +- Detailed error handling |
17 | 13 |
|
18 | | -## Getting Started |
| 14 | +## Quick Start |
19 | 15 |
|
20 | 16 | ### Prerequisites |
21 | 17 |
|
22 | | -- Rust 1.70 or higher |
23 | | -- Redis 6.0 or higher |
24 | | -- Cargo (Rust's package manager) |
| 18 | +- Rust (latest stable) |
| 19 | +- Redis server (6.0 or higher) |
| 20 | +- Cargo (comes with Rust) |
25 | 21 |
|
26 | 22 | ### Installation |
27 | 23 |
|
28 | 24 | 1. Clone the repository: |
29 | | - ```bash |
30 | | - git clone https://github.com/yourusername/jump.git |
31 | | - cd jump |
32 | | - ``` |
| 25 | +```bash |
| 26 | +git clone https://github.com/codevalley/jump.git |
| 27 | +cd jump |
| 28 | +``` |
33 | 29 |
|
34 | | -2. Copy the example environment file: |
35 | | - ```bash |
36 | | - cp .env.example .env |
37 | | - ``` |
| 30 | +2. Start Redis: |
| 31 | +```bash |
| 32 | +# Using Docker |
| 33 | +docker run --name jump-redis -p 6379:6379 -d redis |
38 | 34 |
|
39 | | -3. Update the environment variables in `.env` with your configuration. |
| 35 | +# Or use your system's Redis |
| 36 | +systemctl start redis # Linux |
| 37 | +brew services start redis # macOS |
| 38 | +``` |
40 | 39 |
|
41 | | -4. Build the project: |
42 | | - ```bash |
43 | | - cargo build --release |
44 | | - ``` |
| 40 | +3. Build and run: |
| 41 | +```bash |
| 42 | +cargo run |
| 43 | +``` |
45 | 44 |
|
46 | | -5. Run the server: |
47 | | - ```bash |
48 | | - cargo run --release |
49 | | - ``` |
| 45 | +The service will start on `http://localhost:8080`. |
50 | 46 |
|
51 | | -## Usage |
| 47 | +## API Overview |
52 | 48 |
|
53 | | -### Creating a Share |
| 49 | +### Health Check |
| 50 | +```http |
| 51 | +GET /api/health |
| 52 | +``` |
54 | 53 |
|
55 | | -```bash |
56 | | -curl -X POST http://localhost:8080/api/v1/payloads \ |
57 | | - -H "Content-Type: application/json" \ |
58 | | - -d '{ |
59 | | - "content": "Your content here", |
60 | | - "mime_type": "text/plain", |
61 | | - "expiry_time": "2024-03-14T12:00:00Z" |
62 | | - }' |
| 54 | +### Create Payload |
| 55 | +```http |
| 56 | +POST /api/v1/payloads |
| 57 | +Content-Type: application/json |
| 58 | +
|
| 59 | +{ |
| 60 | + "content": "Your content here", |
| 61 | + "mime_type": "text/plain", |
| 62 | + "expiry_time": "2025-03-28T00:00:00Z" // Optional |
| 63 | +} |
63 | 64 | ``` |
64 | 65 |
|
65 | | -### Retrieving a Share |
| 66 | +### Get Payload |
| 67 | +```http |
| 68 | +GET /api/v1/payloads/{hash_id} |
| 69 | +``` |
66 | 70 |
|
67 | | -```bash |
68 | | -curl http://localhost:8080/api/v1/payloads/{hash_id} |
| 71 | +### Delete Payload |
| 72 | +```http |
| 73 | +DELETE /api/v1/payloads/{hash_id} |
69 | 74 | ``` |
70 | 75 |
|
| 76 | +For detailed API documentation, see [API.md](docs/API.md). |
| 77 | + |
71 | 78 | ## Configuration |
72 | 79 |
|
73 | 80 | The service can be configured using environment variables: |
74 | 81 |
|
75 | | -- `SERVER_HOST`: Host to bind the server to (default: "127.0.0.1") |
76 | | -- `SERVER_PORT`: Port to listen on (default: 8080) |
77 | | -- `REDIS_URL`: Redis connection URL |
78 | | -- `RATE_LIMIT_REQUESTS`: Number of requests allowed per window |
79 | | -- `RATE_LIMIT_WINDOW_SECS`: Rate limit window in seconds |
80 | | -- `MAX_PAYLOAD_SIZE`: Maximum payload size in bytes |
81 | | -- `DEFAULT_EXPIRY_HOURS`: Default expiry time in hours |
| 82 | +```bash |
| 83 | +# Server configuration |
| 84 | +PORT=8080 |
| 85 | +HOST=127.0.0.1 |
| 86 | + |
| 87 | +# Redis configuration |
| 88 | +REDIS_URL=redis://localhost:6379 |
| 89 | +REDIS_POOL_SIZE=16 |
| 90 | +REDIS_TIMEOUT=5 |
| 91 | + |
| 92 | +# Rate limiting |
| 93 | +RATE_LIMIT_REQUESTS=100 |
| 94 | +RATE_LIMIT_WINDOW=60 # seconds |
| 95 | + |
| 96 | +# Payload limits |
| 97 | +MAX_PAYLOAD_SIZE=10485760 # 10MB |
| 98 | +DEFAULT_EXPIRY=86400 # 24 hours |
| 99 | +``` |
82 | 100 |
|
83 | 101 | ## Development |
84 | 102 |
|
85 | 103 | ### Running Tests |
86 | 104 |
|
87 | 105 | ```bash |
| 106 | +# Run all tests |
88 | 107 | cargo test |
| 108 | + |
| 109 | +# Run specific test suite |
| 110 | +cargo test test_api_integration |
89 | 111 | ``` |
90 | 112 |
|
91 | | -### Documentation |
| 113 | +### Code Style |
92 | 114 |
|
93 | | -Generate and view the documentation: |
| 115 | +The project follows Rust standard formatting. Format your code using: |
94 | 116 |
|
95 | 117 | ```bash |
96 | | -cargo doc --open |
| 118 | +cargo fmt |
97 | 119 | ``` |
98 | 120 |
|
99 | | -## API Documentation |
| 121 | +### Logging |
100 | 122 |
|
101 | | -The API documentation is available at `/api/docs` when running the server. |
| 123 | +The service uses `tracing` for structured logging. Log levels can be configured using the `RUST_LOG` environment variable: |
| 124 | + |
| 125 | +```bash |
| 126 | +RUST_LOG=debug cargo run |
| 127 | +``` |
| 128 | + |
| 129 | +## Project Structure |
| 130 | + |
| 131 | +``` |
| 132 | +src/ |
| 133 | +├── api/ # HTTP API layer |
| 134 | +│ ├── middleware/ # Rate limiting, logging |
| 135 | +│ └── v1/ # API version 1 endpoints |
| 136 | +├── application/ # Business logic |
| 137 | +│ ├── use_cases/ # Core operations |
| 138 | +│ └── dto/ # Data transfer objects |
| 139 | +├── domain/ # Core domain models |
| 140 | +├── infrastructure/ # External services |
| 141 | +│ └── redis/ # Redis implementation |
| 142 | +└── main.rs # Application entry point |
| 143 | +``` |
102 | 144 |
|
103 | 145 | ## Contributing |
104 | 146 |
|
105 | 147 | 1. Fork the repository |
106 | 148 | 2. Create your feature branch (`git checkout -b feature/amazing-feature`) |
107 | | -3. Commit your changes (`git commit -m 'Add some amazing feature'`) |
| 149 | +3. Commit your changes (`git commit -m 'Add amazing feature'`) |
108 | 150 | 4. Push to the branch (`git push origin feature/amazing-feature`) |
109 | 151 | 5. Open a Pull Request |
110 | 152 |
|
111 | 153 | ## License |
112 | 154 |
|
113 | 155 | This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
| 156 | + |
| 157 | +## Acknowledgments |
| 158 | + |
| 159 | +- Built with [actix-web](https://actix.rs/) |
| 160 | +- Storage powered by [Redis](https://redis.io/) |
| 161 | +- Logging with [tracing](https://docs.rs/tracing) |
0 commit comments