-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
28 lines (25 loc) · 754 Bytes
/
Copy pathapp.js
File metadata and controls
28 lines (25 loc) · 754 Bytes
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
const mongo = require('mongodb');
const nconf = require('nconf');
const chalk = require('chalk');
const cron = require('node-cron');
// load config file
nconf.argv().env().file({ file: __dirname + '/config.json' });
const rss = require('./rss');
// connect to MongoDB
var dbo = null;
mongo.connect(nconf.get('mongodbURL'), {
useNewUrlParser: true
}, (err, db) => {
if (err) {
console.log(chalk.red(err));
process.exit(0);
}
dbo = db.db('codeforgeek');
global.db = dbo;
console.log(`${chalk.green('✓')} Connected to ${chalk.green('MongoDB')} database`);
});
// run rss generation every 24 hour at 12:00 AM
cron.schedule('0 0 0 * * *', () => {
// start rss feed generation process
rss.generateRss();
});