File tree 3 files changed +9
-19
lines changed
3 files changed +9
-19
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ const exitWithError = (message) => {
22
22
process . exit ( 1 )
23
23
}
24
24
25
- const download = async ( ) => {
25
+ const getARDFeed = async ( ) => {
26
26
// download ard feed
27
27
const response = await undici . fetch ( ARD_FEED_URL )
28
28
const feed = await response . json ( )
@@ -76,13 +76,8 @@ const download = async () => {
76
76
}
77
77
}
78
78
79
- // save to local storage
80
- await Bun . write (
81
- `${ __dirname } /../data/ard-core-livestreams.json` ,
82
- JSON . stringify ( feed , null , '\t' )
83
- )
84
79
console . log ( 'ARD feed downloaded successfully' )
85
- return null
80
+ return feed
86
81
}
87
82
88
- download ( )
83
+ module . exports = getARDFeed
Original file line number Diff line number Diff line change @@ -17,23 +17,18 @@ const response = require('../../utils/response')
17
17
const config = require ( '../../../config' )
18
18
19
19
// load api feed
20
- const feed = require ( '../../data' )
20
+ const getArdFeed = require ( '../../data' )
21
21
22
22
const source = 'ingest/subscriptions/post'
23
23
24
24
module . exports = async ( req , res ) => {
25
- // check if env was set
26
- if ( ! process . env . ARD_FEED_URL )
27
- console . log ( 'Feed-URL was not set' )
28
-
29
- const coreApi = require ( '../../data/ard-core-livestreams.json' )
30
-
31
25
try {
32
26
// generate subscription name
33
27
const prefix = `${ config . pubSubPrefix } subscription.`
34
28
35
29
// check existence of user institution
36
- const institutionExists = coreApi . items . some ( ( entry ) => {
30
+ const ardFeed = await getArdFeed ( )
31
+ const institutionExists = ardFeed . items . some ( ( entry ) => {
37
32
return req . user . institutionId === entry . publisher . institution . id
38
33
} )
39
34
Original file line number Diff line number Diff line change 4
4
by SWR Audio Lab
5
5
6
6
*/
7
- const feed = require ( '../../data' )
7
+ const getArdFeed = require ( '../../data' )
8
8
9
9
module . exports = async ( publisherId ) => {
10
- const coreApi = require ( '../../data/ard-core-livestreams.json' )
11
10
12
- const publisher = coreApi . items . find ( ( entry ) => {
11
+ const ardFeed = await getArdFeed ( )
12
+ const publisher = ardFeed . items . find ( ( entry ) => {
13
13
return publisherId === entry . publisher . id ? entry . publisher : null
14
14
} )
15
15
You can’t perform that action at this time.
0 commit comments