-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
35 lines (26 loc) · 987 Bytes
/
index.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
#!/usr/bin/env node
var auth = require('http-auth');
var config = require('nconf');
var express = require('express');
var later = require('later');
var scraperbike = require('./src/scraperbike.js');
config.file({ file: 'config.json' }).env().argv();
//every 20 minutes on weekdays between 8am and 7pm fire a scrape
later.date.localTime();
var sched = later.parse.recur().every(20).minute().after(8).hour().before(19).hour().onWeekday();
later.setInterval(scraperbike.fire, sched);
var basic = auth.basic({
realm: config.get('publishTitle')
}, function (username, password, callback) {
callback(username === config.get('username') && password === config.get('password'));
}
);
var app = express();
app.use(auth.connect(basic));
app.get("/calendar", function(req, res){
res.header('Content-Type', 'text/calendar; charset=utf-8');
res.sendFile(__dirname + '/calendar.ics');
});
var port = process.env.PORT || 5000;
app.listen(port);
scraperbike.fire();