feat(server): 添加认证授权和日志记录功能

- 实现了 JWT 认证中间件,支持 token 验证和白名单路由
- 添加了登录接口,支持用户登录和 token 生成
- 集成了 log4js 日志系统,支持 mysql 和 koa 日志分类
- 配置了环境变量支持,添加了 SECRET_KEY 配置
- 重构了 MySQL 连接池配置,添加了查询日志记录
- 集成了 koa 路由和认证中间件,实现接口访问控制
This commit is contained in:
2025-12-24 23:48:14 +08:00
parent 18600b3015
commit 293fbd8bc8
9 changed files with 91 additions and 9 deletions

View File

@@ -5,13 +5,15 @@
"main": "koa/index.js",
"type": "module",
"scripts": {
"start": "node index.js",
"dev": "nodemon index.js"
"start": "node --env-file=.env index.js",
"dev": "nodemon --exec \"node --env-file=.env\" index.js"
},
"dependencies": {
"jsonwebtoken": "^9.0.3",
"koa": "^2.15.0",
"koa-router": "^12.0.0",
"koa-static": "^5.0.0",
"log4js": "^6.9.1",
"mysql2": "^3.16.0"
}
}