# API Test Guide

This document contains `curl` commands to test the endpoints of the File Sharing API. 

*Note: You must have a dummy `test.pdf` file in the directory where you run the upload commands. Replace `<shareId>` with an actual ID returned from the upload endpoints.*

---

## 1. Health Check

**Command:**
```bash
curl http://localhost:3001/health
```

**Expected Response:**
```json
{
  "status": "ok"
}
```

---

## 2. Upload File (No Password)

**Command:**
```bash
curl -X POST http://localhost:3001/api/files/upload \
  -F "file=@./test.pdf" \
  -F "expiryHours=1"
```

**Expected Response:**
```json
{
  "success": true,
  "message": "File uploaded successfully",
  "data": {
    "shareId": "a1b2c3d4e5f6",
    "shareLink": "http://localhost:3001/f/a1b2c3d4e5f6",
    "expiresAt": "2026-10-06T11:00:00.000Z",
    "hasPassword": false
  }
}
```

---

## 3. Upload File (With Password)

**Command:**
```bash
curl -X POST http://localhost:3001/api/files/upload \
  -F "file=@./test.pdf" \
  -F "password=secret123" \
  -F "expiryHours=24" \
  -F "recipientEmail=test@example.com"
```

**Expected Response:**
```json
{
  "success": true,
  "message": "File uploaded successfully",
  "data": {
    "shareId": "f6e5d4c3b2a1",
    "shareLink": "http://localhost:3001/f/f6e5d4c3b2a1",
    "expiresAt": "2026-10-07T10:00:00.000Z",
    "hasPassword": true
  }
}
```

---

## 4. Get Meta

**Command:**
```bash
curl http://localhost:3001/api/files/<shareId>/meta
```

**Expected Response:**
```json
{
  "success": true,
  "message": "Success",
  "data": {
    "originalName": "test.pdf",
    "fileSize": 1048576,
    "mimeType": "application/pdf",
    "hasPassword": true,
    "expiresAt": "2026-10-07T10:00:00.000Z",
    "downloadCount": 0
  }
}
```

---

## 5. Verify Password

**Command:**
```bash
curl -X POST http://localhost:3001/api/files/<shareId>/verify \
  -H "Content-Type: application/json" \
  -d '{"password":"secret123"}'
```

**Expected Response:**
```json
{
  "success": true,
  "message": "Success",
  "data": {
    "valid": true
  }
}
```

---

## 6. Download

**Command:**
```bash
curl -O "http://localhost:3001/api/files/<shareId>/download?password=secret123"
```

**Expected Response:**
*(No JSON response. The command will download the binary stream and save it to your local directory).*

---

## 7. Revoke

**Command:**
```bash
curl -X DELETE http://localhost:3001/api/files/<shareId> \
  -H "Content-Type: application/json" \
  -d '{"password":"secret123"}'
```

**Expected Response:**
```json
{
  "success": true,
  "message": "File revoked successfully",
  "data": null
}
```
