Skip to content

Commit c9811ee

Browse files
committed
docs
1 parent bf833ea commit c9811ee

File tree

1 file changed

+177
-47
lines changed

1 file changed

+177
-47
lines changed

docs/api.md

Lines changed: 177 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,68 @@ X-RateLimit-Reset: 1640995200
5656

5757
## Endpoints
5858

59+
### System Operations
60+
61+
#### Health Check
62+
```http
63+
GET /health
64+
```
65+
Returns health status of all services (MinIO, AWS, Cache).
66+
67+
Response:
68+
```json
69+
{
70+
"status": "healthy",
71+
"services": {
72+
"minio": "connected",
73+
"aws": "connected",
74+
"cache": "connected"
75+
},
76+
"timestamp": "2024-01-15T10:30:00Z"
77+
}
78+
```
79+
80+
#### Metrics
81+
```http
82+
GET /metrics
83+
```
84+
Returns Prometheus format metrics.
85+
86+
#### WebSocket Connection
87+
```http
88+
GET /ws
89+
```
90+
Establishes WebSocket connection for real-time monitoring.
91+
92+
#### Monitor Stats
93+
```http
94+
GET /monitor
95+
```
96+
Returns current system statistics.
97+
98+
Response:
99+
```json
100+
{
101+
"status": true,
102+
"message": "success",
103+
"data": {
104+
"timestamp": "2024-01-15T10:30:00Z",
105+
"active_uploads": 5,
106+
"upload_speed": 1048576,
107+
"cache_hit_rate": 85.5,
108+
"cpu_usage": 45.2,
109+
"memory_usage": 60.8,
110+
"disk_usage": {
111+
"/data": 75,
112+
"/uploads": 45
113+
},
114+
"errors": [
115+
"Failed to process image: invalid format"
116+
]
117+
}
118+
}
119+
```
120+
59121
### Image Operations
60122

61123
#### Get Image
@@ -86,42 +148,132 @@ Body:
86148
- `bucket`: Bucket name
87149
- `path`: Storage path (optional)
88150
- `aws_upload`: Boolean flag for AWS upload (optional)
151+
- `width`: Target width in pixels (optional)
152+
- `height`: Target height in pixels (optional)
153+
154+
Response: Standard success response
155+
156+
#### Batch Upload
157+
```http
158+
POST /batch/upload
159+
```
160+
Headers:
161+
- `Content-Type: multipart/form-data`
162+
- `Authorization: Bearer <token>`
163+
164+
Body:
165+
- `files[]`: Multiple image files (max 10)
166+
- `bucket`: Target bucket name
167+
- `path`: Storage path (optional)
168+
- `aws_upload`: Boolean flag for AWS upload (optional)
169+
- `width`: Target width in pixels (optional)
170+
- `height`: Target height in pixels (optional)
89171

90172
Response:
91173
```json
92174
{
93175
"status": true,
94-
"message": "Success",
95-
"data": {
96-
"minioUpload": "Minio Successfully Uploaded size 1024",
97-
"minioResult": {
98-
"bucket": "test-bucket",
99-
"key": "path/image.jpg",
100-
"size": 1024
176+
"message": "Batch upload successful",
177+
"data": [
178+
{
179+
"filename": "image1.jpg",
180+
"success": true,
181+
"result": {...}
101182
},
102-
"awsUpload": "S3 Successfully Uploaded",
103-
"awsResult": "...",
104-
"imageName": "image.jpg",
105-
"objectName": "path/image.jpg",
106-
"link": "https://cdn.example.com/bucket/path/image.jpg"
107-
}
183+
{
184+
"filename": "image2.jpg",
185+
"success": true,
186+
"result": {...}
187+
}
188+
]
108189
}
109190
```
110191

111-
#### Upload Image with AWS
192+
#### Upload from URL
112193
```http
113-
POST /upload-with-aws
194+
POST /upload-url
195+
```
196+
Headers:
197+
- `Content-Type: application/json`
198+
- `Authorization: Bearer <token>`
199+
200+
Body:
201+
```json
202+
{
203+
"url": "https://example.com/image.jpg",
204+
"bucket": "my-bucket",
205+
"path": "optional/path",
206+
"aws_upload": false
207+
}
114208
```
115-
Similar to `/upload` but stores in both Minio and AWS S3.
116209

117-
#### Upload Image from URL
210+
Response: Standard success response
211+
212+
#### Resize Image
118213
```http
119-
POST /upload-url
214+
POST /resize
120215
```
216+
Headers:
217+
- `Content-Type: multipart/form-data`
218+
- `Authorization: Bearer <token>`
219+
121220
Body:
122-
- `url`: Source image URL
221+
- `file`: Image file
222+
- `width`: Target width in pixels (optional)
223+
- `height`: Target height in pixels (optional)
224+
225+
Response: Resized image file
226+
227+
#### Delete Image
228+
```http
229+
DELETE /:bucket/*
230+
```
231+
Parameters:
123232
- `bucket`: Bucket name
124-
- `path`: Storage path (optional)
233+
- `*`: Image path
234+
- `aws_delete`: Boolean query parameter for AWS deletion (optional)
235+
236+
Response: Standard success response
237+
238+
#### Batch Delete
239+
```http
240+
DELETE /batch/delete
241+
```
242+
Headers:
243+
- `Content-Type: application/json`
244+
- `Authorization: Bearer <token>`
245+
246+
Body:
247+
```json
248+
{
249+
"bucket": "my-bucket",
250+
"files": [
251+
"path/to/image1.jpg",
252+
"path/to/image2.jpg"
253+
],
254+
"aws_delete": false
255+
}
256+
```
257+
258+
Response:
259+
```json
260+
{
261+
"status": true,
262+
"message": "Batch deletion successful",
263+
"data": [
264+
{
265+
"filename": "image1.jpg",
266+
"success": true,
267+
"error": null
268+
},
269+
{
270+
"filename": "image2.jpg",
271+
"success": true,
272+
"error": null
273+
}
274+
]
275+
}
276+
```
125277

126278
### Storage Operations
127279

@@ -140,32 +292,6 @@ GET /minio/:bucket/create
140292
GET /minio/:bucket/delete
141293
```
142294

143-
### Monitoring
144-
```http
145-
GET /metrics
146-
```
147-
Returns Prometheus metrics for:
148-
- HTTP request counts
149-
- Request durations
150-
- Image processing durations
151-
- Storage operation durations
152-
153-
## Error Responses
154-
```json
155-
{
156-
"status": false,
157-
"message": "Error description",
158-
"data": null
159-
}
160-
```
161-
162-
Common HTTP Status Codes:
163-
- 200: Success
164-
- 400: Bad Request
165-
- 401: Unauthorized
166-
- 429: Too Many Requests
167-
- 500: Internal Server Error
168-
169295
## Error Codes
170296
- `RATE_LIMIT_EXCEEDED`: Request rate limit exceeded
171297
- `INVALID_TOKEN`: Authentication token is invalid
@@ -174,4 +300,8 @@ Common HTTP Status Codes:
174300
- `INVALID_FILE_TYPE`: Unsupported file type
175301
- `STORAGE_ERROR`: Error during storage operation
176302
- `AWS_UPLOAD_FAILED`: AWS S3 upload failed
177-
- `MINIO_UPLOAD_FAILED`: MinIO upload failed
303+
- `MINIO_UPLOAD_FAILED`: MinIO upload failed
304+
- `BATCH_SIZE_EXCEEDED`: Too many files in batch operation
305+
- `BATCH_OPERATION_FAILED`: Batch operation partially failed
306+
- `CIRCUIT_BREAKER_OPEN`: Service temporarily unavailable
307+
- `TOO_MANY_REQUESTS`: Concurrent request limit exceeded

0 commit comments

Comments
 (0)