22const Redis = require ( 'ioredis' ) ;
33
44// LOCAL FUNCTIONS
5+ const logger = require ( '../utils/logger' ) ;
56const getWorldometerPage = require ( '../scrapers/getWorldometers' ) ;
67const getStates = require ( '../scrapers/getStates' ) ;
78const jhuLocations = require ( '../scrapers/jhuLocations' ) ;
89const historical = require ( '../scrapers/historical' ) ;
910const nytData = require ( '../scrapers/nytData' ) ;
1011
1112// KEYS
12- const keys = require ( '../config.keys.json' ) ;
13-
14- let config ;
15- try {
16- config = require ( '../config.json' ) ;
17- } catch ( err ) {
18- config = require ( '../config.example.json' ) ;
19- }
13+ const { config, keys } = require ( '../config' ) ;
2014
2115const redis = new Redis ( config . redis . host , {
2216 password : config . redis . password ,
@@ -32,6 +26,20 @@ module.exports = {
3226 getStates,
3327 jhuLocations,
3428 historical,
35- nytData
29+ nytData,
30+ executeScraper : async ( ) => {
31+ await Promise . all ( [
32+ getWorldometerPage ( keys , redis ) ,
33+ getStates ( keys , redis ) ,
34+ jhuLocations . jhudataV2 ( keys , redis ) ,
35+ historical . historicalV2 ( keys , redis ) ,
36+ historical . getHistoricalUSADataV2 ( keys , redis )
37+ ] ) ;
38+ logger . info ( 'Finished scraping!' ) ;
39+ } ,
40+ executeScraperNYTData : async ( ) => {
41+ await nytData ( keys , redis ) ;
42+ logger . info ( 'Finished NYT scraping!' ) ;
43+ }
3644 }
3745} ;
0 commit comments