(
url: string | Request | URL,
options: RequestInit = {},
)
| 27 | let fetchCount = 0 |
| 28 | |
| 29 | const fetchClient: typeof fetch = async ( |
| 30 | url: string | Request | URL, |
| 31 | options: RequestInit = {}, |
| 32 | ) => { |
| 33 | const thisFetchCount = fetchCount++ |
| 34 | if (LOG_FETCH) { |
| 35 | console.log('>> fetch', thisFetchCount, url, options) |
| 36 | } |
| 37 | let table: string | null = null |
| 38 | if (typeof url === 'string') { |
| 39 | table = new URL(url).searchParams.get('table') |
| 40 | } else if (url instanceof Request) { |
| 41 | table = new URL(url.url).searchParams.get('table') |
| 42 | } else if (url instanceof URL) { |
| 43 | table = url.searchParams.get('table') |
| 44 | } |
| 45 | let res: Response |
| 46 | try { |
| 47 | res = await fetch(url, options) |
| 48 | } catch (e) { |
| 49 | if (LOG_FETCH) { |
| 50 | console.log('>> fetch error', thisFetchCount, e) |
| 51 | } |
| 52 | throw e |
| 53 | } |
| 54 | if (table) { |
| 55 | shapeHandles.set(res.headers.get('electric-handle')!, table) |
| 56 | } |
| 57 | if (LOG_FETCH) { |
| 58 | console.log( |
| 59 | '>> fetch res', |
| 60 | thisFetchCount, |
| 61 | res.status, |
| 62 | res.statusText, |
| 63 | res.headers, |
| 64 | ) |
| 65 | } |
| 66 | return res |
| 67 | } |
| 68 | |
| 69 | const deleteShape = async (table: string, handle: string) => { |
| 70 | const deleteUrl = new URL(ELECTRIC_URL) |
nothing calls this directly
no test coverage detected
searching dependent graphs…