向宁
11315fd00b
feat: wire Watermill CQRS — EventBus in usecases, event handlers, router lifecycle
...
- Add EventPublisher interface in biz layer for domain event publishing
- Wire EventBusPublisher (Watermill EventBus adapter) into FileUsecase, FolderUsecase, ShareUsecase
- Publish events after UploadFile, DeleteFile, CreateFolder, DeleteFolder, CreateShare
- Implement CQRSHandler with logging event handlers for all 6 event types
- Register event handlers via CQRSBus.RegisterHandlers using Watermill EventProcessor
- Store subscriber and wmLogger in CQRSBus for EventProcessor wiring
- Expose SqlDB() on Data struct for Watermill SQL pub/sub
- Start Watermill router in goroutine alongside Kratos app with graceful close
- Use appContext wrapper struct to pass CQRSBus through Wire DI graph
2026-05-25 13:52:05 +08:00
向宁
3eb1a1839d
feat: add JWT auth middleware with public endpoint selector
...
Add HS256 JWT authentication to both HTTP and gRPC servers using
Kratos jwt middleware with selector to skip auth for public share
endpoints (GetShareInfo, DownloadShare). Wire DI updated to inject
conf.Auth into server constructors.
2026-05-25 13:43:34 +08:00
向宁
95f76bbc70
chore: remove leftover grpc auth client (will be re-integrated as Kratos middleware)
2026-05-25 13:14:52 +08:00
向宁
42addaea7d
feat: add Wire DI and rewrite main.go as Kratos app entry point
...
- Create wire.go with interface bindings (biz interfaces → data implementations)
- Rewrite main.go to use Kratos config loading + Wire-generated initApp
- Remove temporary deps.go pinning file
- Wire generates complete dependency graph: config → data → biz → service → server → app
2026-05-25 13:12:18 +08:00
向宁
dfaead4766
feat: add Watermill CQRS setup with commands, events, and handler stubs
2026-05-25 13:08:55 +08:00
向宁
b9edb7b7de
feat: add server layer with HTTP and gRPC transport
...
Create internal/server package with HTTP and gRPC server constructors
using Kratos transport layer. Includes Wire provider set for DI,
recovery/tracing/logging middleware, and graceful nil-safe config handling.
Fix .gitignore 'server' pattern to only match root-level binary.
2026-05-25 13:05:33 +08:00
向宁
2647314fe7
feat: add service layer implementing proto FileService interface
...
Implements all 23 FileServiceServer methods: file upload/download/list/
preview/content/delete, multipart upload lifecycle, bucket CRUD, folder
CRUD with tree support, file-to-folder upload, file move, and share link
create/delete/info/download. Includes PO-to-proto conversion helpers.
2026-05-25 13:04:01 +08:00
向宁
4927de90cc
feat: add biz layer with usecases for file, bucket, folder, share
...
Defines repo interfaces in biz (dependency inversion) implemented by data layer.
Removes old domain layer replaced by data layer in previous commit.
2026-05-25 13:00:48 +08:00
向宁
bcd637387a
feat: add data layer with GORM models, S3 repo, PG repos
...
Replace old infrastructure layer with Kratos-style data layer:
- data.go: GORM connection, transaction support, Wire ProviderSet, PO models
- file_repo.go: All 12 S3 operations (upload, download, multipart, presign, buckets)
- folder_repo.go: GORM queries including recursive CTE for descendant files
- file_meta_repo.go: CRUD + move operations for file metadata
- share_repo.go: CRUD + increment download count for share links
Deleted old infrastructure/database, infrastructure/repository, infrastructure/s3.
Kept infrastructure/grpc for later integration.
2026-05-25 12:57:42 +08:00
向宁
7faddfed05
feat: add shared sanitize and s3errors packages
2026-05-25 12:52:39 +08:00
向宁
b9b5838938
chore: add Kratos, Watermill, GORM, Wire dependencies for migration
...
Add new framework dependencies needed for the Gin-to-Kratos migration:
- go-kratos/kratos/v2 (HTTP/gRPC transport, config, middleware, JWT auth)
- google/wire (compile-time dependency injection)
- ThreeDotsLabs/watermill + watermill-sql/v2 (event-driven CQRS)
- gorm.io/gorm + gorm.io/driver/postgres (PostgreSQL ORM)
The old Gin/Swagger deps remain as direct deps since existing code still
imports them. They will be removed in later migration tasks when code is
rewritten. Blank imports in internal/deps.go ensure go mod tidy keeps
the new deps until actual code imports them directly.
2026-05-25 12:51:26 +08:00
向宁
ed47904a85
chore: initialize Kratos project skeleton, add proto config and Makefile
...
- Add Makefile with api/config/wire/build/run/test/clean targets
- Update buf.yaml with api, internal/conf, and third_party modules
- Update buf.gen.yaml with protobuf, grpc, and grpc-gateway plugins
- Add internal/conf/conf.proto (Kratos config schema: Bootstrap/Server/Data/Auth)
- Generate internal/conf/conf.pb.go via buf
- Add configs/config.yaml with HTTP/gRPC server, Postgres, S3, and auth settings
- Add third_party/google/api proto files (annotations, http)
- Remove old Gin-based layers: internal/api, internal/infrastructure/mediator,
internal/middleware, internal/common, docs
- Update .gitignore to exclude server binary and bin/
2026-05-25 12:37:45 +08:00
向宁
654b7d9bb6
chore: initial commit before Kratos migration
2026-05-25 12:29:31 +08:00
向宁
3a18ca0579
feat: add directory structure and file sharing support
...
- PostgreSQL metadata overlay layer on top of existing S3 storage
- 3 new tables: folders, files, share_links
- Folder CRUD: create, get with children, tree, rename, delete (cascade)
- File operations: upload to folder, move between folders
- Share links: create with optional password/expiry/download limit, public access
- S3 compensation on PG write failure
- Existing 14 endpoints untouched
2026-05-20 20:26:19 +08:00
向宁
b5df6445e5
refactor: commit all pending file_system changes
...
- Restructure handlers into file_commands/file_queries/file_handlers
- Add gRPC auth client, JWT middleware, rate limiting, request ID
- Add common utilities: logger, sanitizer, s3_errors
- Add unit tests for config, mediator, auth, request_id, sanitize
- Add proto definitions and generated code
- Remove old web UI pages
- Add .dockerignore and .env.example
2026-05-17 22:20:02 +08:00
向宁
d3015d63f2
feat: add OpenTelemetry tracing, metrics, and logging
...
- Create internal/common/otel.go with InitOTel() for tracing + metrics + logs
- Add otelgin middleware for automatic Gin HTTP span creation
- Add OTelEndpoint config (default: 192.168.1.154:4316)
- Export all signals via OTLP gRPC to OTel Collector
2026-05-17 22:08:03 +08:00
root
d861be0d6e
feat: 新增文件文本内容接口,修复Markdown预览
...
- 新增 GET /files/content 接口,后端直接读取S3文件文本内容返回
- Repository 新增 GetFileContent 方法
- CQRS: 新增 GetFileContentQuery / GetFileContentHandler
- 前端 Markdown 预览改为调用后端接口获取内容,用 marked.js 渲染
- 解决 presigned URL CORS 和下载头导致 MD 文件无法预览的问题
- config.go: AuthAPIKey 默认值恢复为 xn001624.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-06 18:08:42 +08:00
root
f5a906a208
feat: 修复API密钥默认值 & 添加Markdown文件预览支持
...
- config.go: AuthAPIKey 默认值从空字符串恢复为 xn001624.
- index.html: 引入 marked.js,支持 .md/.markdown 文件渲染预览
- 新增 markdown 预览类型,自动获取内容并渲染为 HTML
- 文件图标识别 md 文件显示为代码文件图标
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-06 15:25:05 +08:00
root
9efd78aaff
fix: 修正 RustFS 连接地址,移除硬编码密钥
...
- 修正 RustFS 端点地址为 192.168.1.154:9000(对应服务器实际部署)
- 移除 config.go 中硬编码的 AccessKey/SecretKey 默认值,改为环境变量传入
- 移除 middleware/auth.go 中硬编码的 API_KEY_VALUE 常量,改为参数注入
- 新增 Config.AuthAPIKey 字段,通过 AUTH_API_KEY 环境变量配置
- 移除 login.html 页面上的密钥格式提示,防止信息泄露
- docker-compose.yml 补全 RustFS 连接所需的环境变量
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-05 17:02:01 +08:00
root
54f66c56ed
feat: 添加 Web UI 登录功能
...
为 Web UI 添加完整的登录验证系统,遵循 CQRS 架构模式。
主要功能:
- 创建登录页面 UI (web/login.html)
- 美观的渐变背景设计
- 密钥输入和验证
- 错误提示和加载状态
- 实现登录验证 (遵循 CQRS)
- 新增 LoginQuery 和 LoginHandler (internal/api/handlers/auth_handlers.go)
- 新增 AuthEndpoint (internal/api/endpoints/auth_endpoints.go)
- 注册登录接口 /auth/login (无需授权)
- 更新主页面 (web/index.html)
- 添加登录状态检查
- 未登录显示提示信息
- 所有 API 请求自动携带 X-API-Key 头
- 添加退出登录功能
- 401 错误自动跳转登录页
- 更新路由配置 (cmd/server/main.go)
- 添加 /auth/login 公开路由
- 注册登录处理器和端点
- 新增登录文档 (docs/LOGIN_GUIDE.md)
- 完整的使用说明
- 技术实现细节
- API 接口说明
安全特性:
- 密钥存储在 localStorage
- 自动处理登录过期
- 支持主动退出登录
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-05 20:27:45 +08:00
root
11fc10ba8a
feat: 添加API授权中间件
...
为所有API接口添加授权验证,要求请求头中包含有效的API密钥才能访问。
主要变更:
- 新增授权中间件 (internal/middleware/auth.go)
- 验证 X-API-Key 请求头
- 密钥值为 xn001624.
- 无效密钥返回 401 Unauthorized
- 更新路由配置 (cmd/server/main.go)
- 使用路由组统一应用授权中间件
- 保护所有文件和存储桶操作接口
- Swagger 和 Web UI 保持公开访问
- 新增授权使用文档 (docs/AUTH_GUIDE.md)
- 多语言使用示例 (cURL, JavaScript, Python)
- 完整的错误说明和授权范围
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-05 20:22:04 +08:00
root
5b66e7d3e7
修改 s3 地址
2026-01-05 19:51:19 +08:00
root
00a0e583a8
添加存储桶删除功能
...
- 新增 DeleteBucketHandler 处理存储桶删除请求
- 添加 DELETE /buckets API 端点
- 在前端界面添加删除存储桶按钮功能
- 添加存储桶删除请求验证器
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-19 16:40:09 +08:00
root
71a5ea5f41
添加文件删除功能
2025-12-19 16:32:20 +08:00
root
8232827835
Initial commit
2025-12-18 09:34:49 +08:00