| 48 | >; |
| 49 | |
| 50 | function createWrapperFunction<TFn extends (...args: Array<any>) => any>( |
| 51 | h3Function: TFn, |
| 52 | ): WrapFunction<TFn> { |
| 53 | return ((...args: Array<any>) => { |
| 54 | const event = args[0]; |
| 55 | if (!isEvent(event)) { |
| 56 | args.unshift(getEvent()); |
| 57 | } else { |
| 58 | args[0] = |
| 59 | event instanceof h3.H3Event || (event as any).__is_event__ ? event : event[HTTPEventSymbol]; |
| 60 | } |
| 61 | |
| 62 | return (h3Function as any)(...args); |
| 63 | }) as any; |
| 64 | } |
| 65 | |
| 66 | // Creating wrappers for each utility and exporting them with their original names |
| 67 | // readRawBody => getWebRequest().text()/.arrayBuffer() |