fix: 服务端验证强化 — 房间ID/坐标/swipe/盲盒竞态/空格

- #15: 房间 ID 扩展为 6 位字母数字,createRoom 用 P2002 重试替代 find-then-create
- #16: 盲盒编辑/删除改用 updateMany/deleteMany 原子操作,防止 TOCTOU
- #17: lat/lng 用 Number.isFinite + 范围校验 (-90~90, -180~180)
- #18: swipe action 必须为 'like' 或 'pass'
- #19: user PUT 的 JSON.parse(preferences) 加 try/catch
- #26: requireString 拒绝纯空格字符串
This commit is contained in:
2026-02-26 20:19:56 +08:00
parent 93f20747e4
commit dfb3cfa136
6 changed files with 41 additions and 31 deletions
+3
View File
@@ -11,6 +11,9 @@ export const POST = apiHandler(async (req, { params }) => {
if (restaurantId == null || !action) {
throw new ApiError("restaurantId and action are required");
}
if (action !== "like" && action !== "pass") {
throw new ApiError("action must be 'like' or 'pass'");
}
const rid = String(restaurantId);