diff --git a/architecture/api-documentation.md b/architecture/api-documentation.md new file mode 100644 index 0000000..6381f9d --- /dev/null +++ b/architecture/api-documentation.md @@ -0,0 +1,119 @@ +# API 文档 + +## 认证接口 + +### POST /api/auth/register +注册新用户 + +**请求体:** +```json +{ + "username": "string", + "password": "string", + "email": "string" +} +``` + +**响应:** +```json +{ + "token": "string", + "userId": number +} +``` + +### POST /api/auth/login +用户登录 + +**请求体:** +```json +{ + "username": "string", + "password": "string" +} +``` + +**响应:** +```json +{ + "token": "string", + "user": { + "id": number, + "username": "string", + "email": "string", + "storageUsed": number, + "storageLimit": number + } +} +``` + +## 文件接口 + +### GET /api/files +获取文件列表 + +**查询参数:** +- `parentId`: 文件夹ID(可选) + +**响应:** +```json +{ + "files": [ + { + "id": 1, + "name": "document.pdf", + "type": "pdf", + "size": 1024000, + "is_folder": false, + "updated_at": "2026-03-10T00:00:00Z" + } + ] +} +``` + +### POST /api/files/upload +上传文件 + +**请求体:** multipart/form-data + +**响应:** +```json +{ + "success": true, + "fileId": 1, + "filename": "document.pdf" +} +``` + +### DELETE /api/files/:id +删除文件 + +**响应:** +```json +{ + "success": true +} +``` + +## 分享接口 + +### POST /api/share +创建分享链接 + +**请求体:** +```json +{ + "fileId": 1, + "password": "optional", + "expiresIn": 86400 +} +``` + +**响应:** +```json +{ + "success": true, + "shareToken": "abc123", + "shareUrl": "/share/abc123" +} +```