-web-service

This commit is contained in:
2025-11-11 15:11:56 +07:00
parent 9ad26fa5ef
commit fcf59ce5db
21 changed files with 537 additions and 253 deletions

View File

@@ -1,4 +1,4 @@
import { sendResponse } from '../utils/response.js'
import { sendError } from '../utils/response.js'
/**
* ✅ Middleware สำหรับตรวจสอบความถูกต้องของ JSON body
@@ -7,7 +7,7 @@ import { sendResponse } from '../utils/response.js'
export function validateJsonFormat(err, req, res, next) {
if (err instanceof SyntaxError && 'body' in err) {
console.error('[Invalid JSON Format]', err.message)
return sendResponse(res, 400, 'รูปแบบ บอร์ดี้ ไม่ถูกต้อง', 'Invalid Body format')
return sendError('รูปแบบ บอร์ดี้ ไม่ถูกต้อง', 'Invalid Body format')
}
next()
}