8
8
import { getCacheTag , getComputedContentSourceCacheTags } from '@gitbook/cache-tags' ;
9
9
import { GITBOOK_API_TOKEN , GITBOOK_API_URL , GITBOOK_USER_AGENT } from '@v2/lib/env' ;
10
10
import { unstable_cacheLife as cacheLife , unstable_cacheTag as cacheTag } from 'next/cache' ;
11
- import { getCloudflareRequestGlobal } from './cloudflare' ;
12
11
import { DataFetcherError , wrapDataFetcherError } from './errors' ;
13
12
import { withCacheKey , withoutConcurrentExecution } from './memoize' ;
14
13
import type { GitBookDataFetcher } from './types' ;
@@ -197,28 +196,24 @@ export function createDataFetcher(
197
196
}
198
197
199
198
const getUserById = withCacheKey (
200
- withoutConcurrentExecution (
201
- getCloudflareRequestGlobal ,
202
- async ( _ , input : DataFetcherInput , params : { userId : string } ) => {
203
- 'use cache' ;
204
- return trace ( `getUserById(${ params . userId } )` , async ( ) => {
205
- return wrapDataFetcherError ( async ( ) => {
206
- const api = apiClient ( input ) ;
207
- const res = await api . users . getUserById ( params . userId , {
208
- ...noCacheFetchOptions ,
209
- } ) ;
210
- cacheTag ( ...getCacheTagsFromResponse ( res ) ) ;
211
- cacheLife ( 'days' ) ;
212
- return res . data ;
199
+ withoutConcurrentExecution ( async ( _ , input : DataFetcherInput , params : { userId : string } ) => {
200
+ 'use cache' ;
201
+ return trace ( `getUserById(${ params . userId } )` , async ( ) => {
202
+ return wrapDataFetcherError ( async ( ) => {
203
+ const api = apiClient ( input ) ;
204
+ const res = await api . users . getUserById ( params . userId , {
205
+ ...noCacheFetchOptions ,
213
206
} ) ;
207
+ cacheTag ( ...getCacheTagsFromResponse ( res ) ) ;
208
+ cacheLife ( 'days' ) ;
209
+ return res . data ;
214
210
} ) ;
215
- }
216
- )
211
+ } ) ;
212
+ } )
217
213
) ;
218
214
219
215
const getSpace = withCacheKey (
220
216
withoutConcurrentExecution (
221
- getCloudflareRequestGlobal ,
222
217
async (
223
218
_ ,
224
219
input : DataFetcherInput ,
@@ -255,7 +250,6 @@ const getSpace = withCacheKey(
255
250
256
251
const getChangeRequest = withCacheKey (
257
252
withoutConcurrentExecution (
258
- getCloudflareRequestGlobal ,
259
253
async (
260
254
_ ,
261
255
input : DataFetcherInput ,
@@ -294,7 +288,6 @@ const getChangeRequest = withCacheKey(
294
288
295
289
const getRevision = withCacheKey (
296
290
withoutConcurrentExecution (
297
- getCloudflareRequestGlobal ,
298
291
async (
299
292
_ ,
300
293
input : DataFetcherInput ,
@@ -325,7 +318,6 @@ const getRevision = withCacheKey(
325
318
326
319
const getRevisionPages = withCacheKey (
327
320
withoutConcurrentExecution (
328
- getCloudflareRequestGlobal ,
329
321
async (
330
322
_ ,
331
323
input : DataFetcherInput ,
@@ -356,7 +348,6 @@ const getRevisionPages = withCacheKey(
356
348
357
349
const getRevisionFile = withCacheKey (
358
350
withoutConcurrentExecution (
359
- getCloudflareRequestGlobal ,
360
351
async (
361
352
_ ,
362
353
input : DataFetcherInput ,
@@ -389,7 +380,6 @@ const getRevisionFile = withCacheKey(
389
380
390
381
const getRevisionPageMarkdown = withCacheKey (
391
382
withoutConcurrentExecution (
392
- getCloudflareRequestGlobal ,
393
383
async (
394
384
_ ,
395
385
input : DataFetcherInput ,
@@ -429,7 +419,6 @@ const getRevisionPageMarkdown = withCacheKey(
429
419
430
420
const getRevisionPageByPath = withCacheKey (
431
421
withoutConcurrentExecution (
432
- getCloudflareRequestGlobal ,
433
422
async (
434
423
_ ,
435
424
input : DataFetcherInput ,
@@ -463,7 +452,6 @@ const getRevisionPageByPath = withCacheKey(
463
452
464
453
const getDocument = withCacheKey (
465
454
withoutConcurrentExecution (
466
- getCloudflareRequestGlobal ,
467
455
async ( _ , input : DataFetcherInput , params : { spaceId : string ; documentId : string } ) => {
468
456
'use cache' ;
469
457
return trace ( `getDocument(${ params . spaceId } , ${ params . documentId } )` , async ( ) => {
@@ -488,7 +476,6 @@ const getDocument = withCacheKey(
488
476
489
477
const getComputedDocument = withCacheKey (
490
478
withoutConcurrentExecution (
491
- getCloudflareRequestGlobal ,
492
479
async (
493
480
_ ,
494
481
input : DataFetcherInput ,
@@ -538,7 +525,6 @@ const getComputedDocument = withCacheKey(
538
525
539
526
const getReusableContent = withCacheKey (
540
527
withoutConcurrentExecution (
541
- getCloudflareRequestGlobal ,
542
528
async (
543
529
_ ,
544
530
input : DataFetcherInput ,
@@ -571,7 +557,6 @@ const getReusableContent = withCacheKey(
571
557
572
558
const getLatestOpenAPISpecVersionContent = withCacheKey (
573
559
withoutConcurrentExecution (
574
- getCloudflareRequestGlobal ,
575
560
async ( _ , input : DataFetcherInput , params : { organizationId : string ; slug : string } ) => {
576
561
'use cache' ;
577
562
cacheTag (
@@ -606,7 +591,6 @@ const getLatestOpenAPISpecVersionContent = withCacheKey(
606
591
607
592
const getPublishedContentSite = withCacheKey (
608
593
withoutConcurrentExecution (
609
- getCloudflareRequestGlobal ,
610
594
async (
611
595
_ ,
612
596
input : DataFetcherInput ,
@@ -647,7 +631,6 @@ const getPublishedContentSite = withCacheKey(
647
631
648
632
const getSiteRedirectBySource = withCacheKey (
649
633
withoutConcurrentExecution (
650
- getCloudflareRequestGlobal ,
651
634
async (
652
635
_ ,
653
636
input : DataFetcherInput ,
@@ -694,7 +677,6 @@ const getSiteRedirectBySource = withCacheKey(
694
677
695
678
const getEmbedByUrl = withCacheKey (
696
679
withoutConcurrentExecution (
697
- getCloudflareRequestGlobal ,
698
680
async ( _ , input : DataFetcherInput , params : { spaceId : string ; url : string } ) => {
699
681
'use cache' ;
700
682
cacheTag (
@@ -727,7 +709,6 @@ const getEmbedByUrl = withCacheKey(
727
709
728
710
const searchSiteContent = withCacheKey (
729
711
withoutConcurrentExecution (
730
- getCloudflareRequestGlobal ,
731
712
async (
732
713
_ ,
733
714
input : DataFetcherInput ,
@@ -771,7 +752,6 @@ const searchSiteContent = withCacheKey(
771
752
772
753
const renderIntegrationUi = withCacheKey (
773
754
withoutConcurrentExecution (
774
- getCloudflareRequestGlobal ,
775
755
async (
776
756
_ ,
777
757
input : DataFetcherInput ,
0 commit comments