路由表化:新增路由匹配器、中间件与表驱动分发,迁移店铺设置/员工/货盘路由

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
黄健铭andClaude Opus 5.5 committed 2026-12-04 12:26:22 -08:00
1 parent 2b9cb825be
commit e082069f55
14 files changed
+525 -197

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
'use strict';
const { fail } = require('../../ledger');
// 保持原样(含按块拼接字符串的已知问题),修正留到下一阶段。
async function readBody(req) {
let raw = '';
for await (const chunk of req) {
raw += chunk;
if (Buffer.byteLength(raw) > 300000) fail('内容过大', 413);
}
try {
return JSON.parse(raw || '{}');
} catch {
fail('请求内容不是有效JSON');
}
}
module.exports = { readBody };