feat(api): 实现 API 路由自动加载并优化路由处理

- 新增 api/example.js 文件作为示例 POST API
- 在 app.js 中添加(bodyParser) 中间件
- 实现 loadAPIRoutes 函数自动加载 API 路由
- 更新 JWT 中间件配置,保护 /login 路由
- 优化路由定义,使用箭头函数
This commit is contained in:
aixianling
2025-02-24 17:46:27 +08:00
parent 4f6d44ec49
commit 18eb590629
4 changed files with 54 additions and 20 deletions

View File

@@ -12,6 +12,7 @@
"dotenv": "^16.4.7",
"jsonwebtoken": "^9.0.2",
"koa": "^2.15.4",
"koa-bodyparser": "^4.4.1",
"koa-jwt": "^4.0.4",
"koa-router": "^13.0.1"
}