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:
@@ -43,7 +43,7 @@ export function validateRoomName(raw: unknown, fallback = "我们的周末"): st
|
||||
}
|
||||
|
||||
export function requireString(value: unknown, fieldName: string): string {
|
||||
if (!value || typeof value !== "string") {
|
||||
if (!value || typeof value !== "string" || !value.trim()) {
|
||||
throw new ApiError(`${fieldName}不能为空`);
|
||||
}
|
||||
return value;
|
||||
|
||||
Reference in New Issue
Block a user