( payload: Record<string, unknown>, field: string, maxBytes: number, )
| 328 | } |
| 329 | |
| 330 | function validateJsonObjectPayload( |
| 331 | payload: Record<string, unknown>, |
| 332 | field: string, |
| 333 | maxBytes: number, |
| 334 | ): void { |
| 335 | assertJsonObject(payload, field); |
| 336 | const payloadBytes = Buffer.byteLength(stringifyJsonObject(payload, field), 'utf8'); |
| 337 | if (payloadBytes > maxBytes) { |
| 338 | throw new AppError('INVALID_ARGS', `${field} exceeds ${maxBytes} bytes`); |
| 339 | } |
| 340 | } |
| 341 | |
| 342 | function assertJsonObject(payload: Record<string, unknown>, field: string): void { |
| 343 | if (!payload || typeof payload !== 'object' || Array.isArray(payload)) { |
no test coverage detected
searching dependent graphs…