@@ -16,13 +16,15 @@ interface GetContentResponse {
16
16
} [ ]
17
17
}
18
18
19
+ const baseUrl = ( endpoint : string ) => endpoint . replace ( / \/ a p i \/ g r a p h q l $ / , '' )
20
+
19
21
const getContent = async (
20
22
endpoint : string ,
21
23
apiKey : string ,
22
24
libraryItemIds : string [ ] ,
23
25
) : Promise < GetContentResponse > => {
24
26
const response = await requestUrl ( {
25
- url : `${ endpoint } /api/content` ,
27
+ url : `${ baseUrl ( endpoint ) } /api/content` ,
26
28
method : 'POST' ,
27
29
headers : {
28
30
'Content-Type' : 'application/json' ,
@@ -80,7 +82,7 @@ const fetchContentForItems = async (
80
82
item . content = await Promise . race ( [
81
83
downloadFromUrl ( c . downloadUrl ) ,
82
84
new Promise < string > (
83
- ( _ , reject ) => setTimeout ( ( ) => reject ( 'Timeout' ) , 600_000 ) , // 10 minutes
85
+ ( _ , reject ) => setTimeout ( ( ) => reject ( 'Timeout' ) , 60_000 ) , // 60 seconds
84
86
) ,
85
87
] )
86
88
} ) ,
@@ -99,7 +101,7 @@ export const getItems = async (
99
101
) : Promise < [ Item [ ] , boolean ] > => {
100
102
const omnivore = new Omnivore ( {
101
103
authToken : apiKey ,
102
- baseUrl : endpoint ,
104
+ baseUrl : baseUrl ( endpoint ) ,
103
105
timeoutMs : 10000 , // 10 seconds
104
106
} )
105
107
@@ -130,7 +132,7 @@ export const deleteItem = async (
130
132
) => {
131
133
const omnivore = new Omnivore ( {
132
134
authToken : apiKey ,
133
- baseUrl : endpoint ,
135
+ baseUrl : baseUrl ( endpoint ) ,
134
136
timeoutMs : 10000 , // 10 seconds
135
137
} )
136
138
0 commit comments