-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp_scraper.js
39 lines (32 loc) · 937 Bytes
/
app_scraper.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
'use strict';
const config = require('./config.js');
const logger4js = require('./logger');
const db = require('./db');
const scraper = require("./scraper/app.js");
const factory = async (dependencies = {}) => {
const {
$db = db(),
$scraper = scraper(),
$config = config(),
$getLogger = logger4js().getLogger
} = dependencies;
const logger = $getLogger($config.appName + '.index ['+process.pid+']');
logger.info("Starting the main script..");
try {
await $db.connect();
await $scraper.start();
}
catch (err) {
logger.fatal("Error while starting the main script");
}
/** MODULE EXPORT **/
return {
};
};
if (module.parent === null) {
// App is not under test. Let's instantiate it with default dependencies.
module.exports = factory();
} else {
// Allow unit tests to inject dependencies
module.exports = factory;
}