修改 wiki

This commit is contained in:
eafonyang
2026-07-09 11:16:59 +08:00
parent b4926ba148
commit 6fab4a86d4
42 changed files with 625 additions and 234 deletions
@@ -0,0 +1,4 @@
- 入口 `src/app.js` 加载 `.env``config/loadEnv.js` 从仓库根目录读取)、注册 CORS/JSON/bodyLimit 中间件、挂载路由数组并调用 `sequelize.sync()` 建表后执行 `ensureBootstrapSuperAdmin` 引导超级管理员。
- 分层组织:`routes/` 按业务域拆分(auth, brands, models, ota, blacklist, otaTargetDevice, shareCodeLogs, users, dashboard),由 `routes/index.js` 汇总导出供 app 遍历挂载;`models/` 使用 Sequelize 定义实体并通过 `index.js` 统一导出;`services/` 封装外部依赖(S3、Redis、Meilisearch、曲线服务);`middleware/` 提供认证与请求体大小限制;`utils/` 暴露 JWT、密码哈希、统一响应格式;`validators/` 以 zod schema 校验入参。
- 认证边界:`middleware/auth.js` 解析 Bearer token 注入 `req.user`,受保护路由在各自文件中通过 `router.use(authMiddleware)` 全局启用,仅 `/health`、根路径等公开接口例外;`requireSuperAdmin` 用于超管专用端点。
- 启动流程:`start.sh``node src/app.js``loadEnv``sequelize.sync()``userBootstrap.ensureBootstrapSuperAdmin()``app.listen(8083)`,异常时降级继续运行。