feat: 实现Vue驱动的云存储系统初始功能
- 后端: Node.js + Express + SQLite架构 - 前端: Vue 3 + Axios实现 - 功能: 用户认证、文件上传/下载、分享链接、密码重置 - 安全: 密码加密、分享链接过期机制、缓存一致性 - 部署: Docker + Nginx容器化配置 - 测试: 完整的边界测试、并发测试和状态一致性测试
This commit is contained in:
52
backend/routes/health.js
Normal file
52
backend/routes/health.js
Normal file
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* 健康检查和公共配置路由
|
||||
* 提供服务健康状态和公共配置信息
|
||||
*/
|
||||
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { SettingsDB } = require('../database');
|
||||
|
||||
/**
|
||||
* 健康检查端点
|
||||
* GET /api/health
|
||||
*/
|
||||
router.get('/health', (req, res) => {
|
||||
res.json({ success: true, message: 'Server is running' });
|
||||
});
|
||||
|
||||
/**
|
||||
* 获取公开的系统配置(不需要登录)
|
||||
* GET /api/config
|
||||
*/
|
||||
router.get('/config', (req, res) => {
|
||||
const maxUploadSize = parseInt(SettingsDB.get('max_upload_size') || '10737418240');
|
||||
res.json({
|
||||
success: true,
|
||||
config: {
|
||||
max_upload_size: maxUploadSize
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* 获取公开的全局主题设置(不需要登录)
|
||||
* GET /api/public/theme
|
||||
*/
|
||||
router.get('/public/theme', (req, res) => {
|
||||
try {
|
||||
const globalTheme = SettingsDB.get('global_theme') || 'dark';
|
||||
res.json({
|
||||
success: true,
|
||||
theme: globalTheme
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('获取全局主题失败:', error);
|
||||
res.status(500).json({
|
||||
success: false,
|
||||
message: '获取主题失败'
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
90
backend/routes/index.js
Normal file
90
backend/routes/index.js
Normal file
@@ -0,0 +1,90 @@
|
||||
/**
|
||||
* 路由模块索引
|
||||
*
|
||||
* 本项目的路由目前主要定义在 server.js 中。
|
||||
* 此目录用于未来路由拆分的模块化重构。
|
||||
*
|
||||
* 建议的路由模块拆分方案:
|
||||
*
|
||||
* 1. routes/health.js - 健康检查和公共配置
|
||||
* - GET /api/health
|
||||
* - GET /api/config
|
||||
* - GET /api/public/theme
|
||||
*
|
||||
* 2. routes/auth.js - 认证相关
|
||||
* - POST /api/login
|
||||
* - POST /api/register
|
||||
* - POST /api/logout
|
||||
* - POST /api/refresh-token
|
||||
* - POST /api/password/forgot
|
||||
* - POST /api/password/reset
|
||||
* - GET /api/verify-email
|
||||
* - POST /api/resend-verification
|
||||
* - GET /api/captcha
|
||||
* - GET /api/csrf-token
|
||||
*
|
||||
* 3. routes/user.js - 用户相关
|
||||
* - GET /api/user/profile
|
||||
* - GET /api/user/theme
|
||||
* - POST /api/user/theme
|
||||
* - POST /api/user/update-oss
|
||||
* - POST /api/user/test-oss
|
||||
* - GET /api/user/oss-usage
|
||||
* - POST /api/user/change-password
|
||||
* - POST /api/user/update-username
|
||||
* - POST /api/user/switch-storage
|
||||
*
|
||||
* 4. routes/files.js - 文件操作
|
||||
* - GET /api/files
|
||||
* - POST /api/files/rename
|
||||
* - POST /api/files/mkdir
|
||||
* - POST /api/files/folder-info
|
||||
* - POST /api/files/delete
|
||||
* - GET /api/files/upload-signature
|
||||
* - POST /api/files/upload-complete
|
||||
* - GET /api/files/download-url
|
||||
* - GET /api/files/download
|
||||
* - POST /api/upload
|
||||
*
|
||||
* 5. routes/share.js - 分享功能
|
||||
* - POST /api/share/create
|
||||
* - GET /api/share/my
|
||||
* - DELETE /api/share/:id
|
||||
* - GET /api/share/:code/theme
|
||||
* - POST /api/share/:code/verify
|
||||
* - POST /api/share/:code/list
|
||||
* - POST /api/share/:code/download
|
||||
* - GET /api/share/:code/download-url
|
||||
* - GET /api/share/:code/download-file
|
||||
*
|
||||
* 6. routes/admin.js - 管理员功能
|
||||
* - GET /api/admin/settings
|
||||
* - POST /api/admin/settings
|
||||
* - POST /api/admin/settings/test-smtp
|
||||
* - GET /api/admin/health-check
|
||||
* - GET /api/admin/storage-stats
|
||||
* - GET /api/admin/users
|
||||
* - GET /api/admin/logs
|
||||
* - GET /api/admin/logs/stats
|
||||
* - POST /api/admin/logs/cleanup
|
||||
* - POST /api/admin/users/:id/ban
|
||||
* - DELETE /api/admin/users/:id
|
||||
* - POST /api/admin/users/:id/storage-permission
|
||||
* - GET /api/admin/users/:id/files
|
||||
* - GET /api/admin/shares
|
||||
* - DELETE /api/admin/shares/:id
|
||||
* - GET /api/admin/check-upload-tool
|
||||
* - POST /api/admin/upload-tool
|
||||
*
|
||||
* 使用示例(在 server.js 中):
|
||||
* ```javascript
|
||||
* const healthRoutes = require('./routes/health');
|
||||
* app.use('/api', healthRoutes);
|
||||
* ```
|
||||
*/
|
||||
|
||||
const healthRoutes = require('./health');
|
||||
|
||||
module.exports = {
|
||||
healthRoutes
|
||||
};
|
||||
Reference in New Issue
Block a user