-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
45 lines (28 loc) · 1.12 KB
/
app.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
40
41
42
43
44
45
/**
* Module dependencies.
*/
const app = require('express')();
const nunjucks = require('nunjucks');
const path = require('path');
const sitemapFunction = require('./sitemap');
const configVars = require('./config');
app.set('view engine', 'html');
nunjucks.configure(['views/'], {
autoescape: false,
express: app,
});
// Routes
require('./routes')(app);
sitemapFunction.untrackedUrls(); // first untracked url call with no interval
// For setInterval function the second parameter is the time in millisecond's make sure to add equivalent millisecond's based on your days
setInterval(sitemapFunction.untrackedUrls, 864000000); // for untracked urls interval is set for 10 days in millisecond's
sitemapFunction.initialSyncCall(); // called only once
setInterval(sitemapFunction.consecutiveSyncCall, configVars.timeInterval); // 2 min interval change per your needs
app.get('/sitemap', (req, res) => {
res.contentType('application/xml');
res.sendFile(path.join(__dirname, 'sitemap.xml'));
});
// load port on 4000
app.listen(configVars.port, () => {
console.log(`Start your browser on port ${configVars.port}`);
});