feat(api): 实现 API 路由自动加载并优化路由处理
- 新增 api/example.js 文件作为示例 POST API - 在 app.js 中添加(bodyParser) 中间件 - 实现 loadAPIRoutes 函数自动加载 API 路由 - 更新 JWT 中间件配置,保护 /login 路由 - 优化路由定义,使用箭头函数
This commit is contained in:
7
api/example.js
Normal file
7
api/example.js
Normal file
@@ -0,0 +1,7 @@
|
||||
// api/example.js
|
||||
module.exports = (ctx) => {
|
||||
ctx.body = {
|
||||
message: 'Example POST API',
|
||||
data: ctx.request.body
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user