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

7
api/example.js Normal file
View File

@@ -0,0 +1,7 @@
// api/example.js
module.exports = (ctx) => {
ctx.body = {
message: 'Example POST API',
data: ctx.request.body
};
};