(res: any)
| 14 | headers.find((header) => header.key.toLowerCase() === 'content-type')?.value ?? ''; |
| 15 | |
| 16 | function parseResponse(res: any): RestResponse { |
| 17 | const headers: Array<KVRow> = res.headers; |
| 18 | const contentType = getContentType(headers); |
| 19 | let body = res.body; |
| 20 | try { |
| 21 | body = beautifyBody(body, contentType); |
| 22 | } catch (e) { |
| 23 | console.error(e); |
| 24 | } |
| 25 | const size = res.size ?? getSize(headers); |
| 26 | |
| 27 | const options: Intl.DateTimeFormatOptions = { |
| 28 | weekday: 'long', |
| 29 | year: 'numeric', |
| 30 | month: 'long', |
| 31 | day: 'numeric', |
| 32 | hour: '2-digit', |
| 33 | minute: '2-digit', |
| 34 | second: '2-digit', |
| 35 | timeZoneName: 'short', |
| 36 | }; |
| 37 | const date = new Date().toLocaleString('en-GB', options); |
| 38 | |
| 39 | return { |
| 40 | headers, |
| 41 | body, |
| 42 | status: res.status, |
| 43 | time: res.time, |
| 44 | size, |
| 45 | date, |
| 46 | }; |
| 47 | } |
| 48 | |
| 49 | export { parseResponse }; |
no test coverage detected