refactor(backend): 优化API文档、认证路由和分页查询,统一响应格式并添加字段验证

This commit is contained in:
2025-09-23 18:38:37 +08:00
parent 00cf840e6f
commit 6d76281c6b
35 changed files with 2027 additions and 535 deletions

42
backend/test-api.js Normal file
View File

@@ -0,0 +1,42 @@
const http = require('http');
function testAPI() {
const options = {
hostname: 'localhost',
port: 4330,
path: '/api/drivers',
method: 'GET',
timeout: 3000
};
const req = http.request(options, (res) => {
console.log(`状态码: ${res.statusCode}`);
console.log(`响应头: ${JSON.stringify(res.headers)}`);
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
console.log('响应体:', data);
process.exit(0);
});
});
req.on('error', (e) => {
console.error('请求错误:', e.message);
process.exit(1);
});
req.on('timeout', () => {
console.error('请求超时');
req.destroy();
process.exit(1);
});
req.end();
}
// 等待2秒让服务器完全启动
setTimeout(testAPI, 2000);