@@ -9,8 +9,8 @@ import { EdenWS } from './ws'
99import {
1010 parseStringifiedDate ,
1111 parseStringifiedValue
12- } from '../utils/parsingUtils '
13- import { ThrowHttpErrors } from '../types'
12+ } from '../utils/parse '
13+ import type { ThrowHttpError } from '../types'
1414
1515const method = [
1616 'get' ,
@@ -26,10 +26,10 @@ const method = [
2626
2727const shouldThrow = (
2828 error : EdenFetchError < number , unknown > ,
29- throwHttpErrors ?: ThrowHttpErrors
29+ throwHttpError ?: ThrowHttpError
3030) : boolean => {
31- if ( typeof throwHttpErrors === 'function' ) return throwHttpErrors ( error )
32- return throwHttpErrors === true
31+ if ( typeof throwHttpError === 'function' ) return throwHttpError ( error )
32+ return throwHttpError === true
3333}
3434
3535const locals = [ 'localhost' , '127.0.0.1' , '0.0.0.0' ]
@@ -126,7 +126,7 @@ const processHeaders = async (
126126
127127function parseSSEBlock (
128128 block : string ,
129- options ?: { parseDates ?: boolean }
129+ options ?: { parseDate ?: boolean }
130130) : Record < string , unknown > | null {
131131 const lines = block . split ( '\n' )
132132 const result : Record < string , unknown > = { }
@@ -155,7 +155,7 @@ function* extractEvents(
155155 bufferRef : {
156156 value : string
157157 } ,
158- options ?: { parseDates ?: boolean }
158+ options ?: { parseDate ?: boolean }
159159) : Generator < Record < string , unknown > > {
160160 let eventEnd : number
161161 while ( ( eventEnd = bufferRef . value . indexOf ( '\n\n' ) ) !== - 1 ) {
@@ -171,7 +171,7 @@ function* extractEvents(
171171
172172export async function * streamResponse (
173173 response : Response ,
174- options ?: { parseDates ?: boolean }
174+ options ?: { parseDate ?: boolean }
175175) {
176176 const body = response . body
177177
@@ -333,13 +333,13 @@ const createProxy = (
333333 ? body . fetch
334334 : options ?. fetch
335335
336- // Per-request throwHttpErrors overrides config
337- const requestThrowHttpErrors =
336+ // Per-request throwHttpError overrides config
337+ const requestThrowHttpError =
338338 isGetOrHead && typeof body === 'object'
339- ? body . throwHttpErrors
340- : options ?. throwHttpErrors
341- const resolvedThrowHttpErrors =
342- requestThrowHttpErrors ?? config . throwHttpErrors
339+ ? body . throwHttpError
340+ : options ?. throwHttpError
341+ const resolvedThrowHttpError =
342+ requestThrowHttpError ?? config . throwHttpError
343343
344344 fetchInit = {
345345 ...fetchInit ,
@@ -532,7 +532,7 @@ const createProxy = (
532532 ) ?? fetcher ! ( url , fetchInit ) )
533533 } catch ( err ) {
534534 const error = new EdenFetchError ( 503 , err )
535- if ( shouldThrow ( error , resolvedThrowHttpErrors ) )
535+ if ( shouldThrow ( error , resolvedThrowHttpError ) )
536536 throw error
537537 return {
538538 data : null ,
@@ -582,7 +582,7 @@ const createProxy = (
582582 ) {
583583 case 'text/event-stream' :
584584 data = streamResponse ( response , {
585- parseDates : config . parseDates
585+ parseDate : config . parseDate
586586 } )
587587 break
588588
@@ -591,7 +591,7 @@ const createProxy = (
591591 if ( typeof v !== 'string' ) return v
592592
593593 const date = parseStringifiedDate ( v , {
594- parseDates : config . parseDates
594+ parseDate : config . parseDate
595595 } )
596596 if ( date ) return date
597597
@@ -617,14 +617,14 @@ const createProxy = (
617617 default :
618618 data = await response . text ( ) . then ( ( text ) =>
619619 parseStringifiedValue ( text , {
620- parseDates : config . parseDates
620+ parseDate : config . parseDate
621621 } )
622622 )
623623 }
624624
625625 if ( response . status >= 300 || response . status < 200 ) {
626626 error = new EdenFetchError ( response . status , data )
627- if ( shouldThrow ( error , resolvedThrowHttpErrors ) )
627+ if ( shouldThrow ( error , resolvedThrowHttpError ) )
628628 throw error
629629 data = null
630630 }
0 commit comments