forked from martinheidegger/kickstarter-update
-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
40 lines (34 loc) · 1.5 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
var kickstarter_update = require("./");
var accounting = require('accounting');
var app = require('express')();
var settings = require("./settings.json");
app.set('view engine', 'hbs');
app.get('/strechGoal1', function(req, res) {
kickstarter_update.requestKickstarterData(settings.kickstarter, function (error, project) {
if(error) {
res.write(error);
} else {
var strechGoal = settings.kickstarter.strechGoal[0];
var percent = project.pledged/strechGoal;
if(percent > 1.0) percent = 1.0;
res.render('strechGoal1', {
'pledged': accounting.formatMoney(project.pledged, {precision:0, symbol:settings.kickstarter.currency}),
'percentToStrechGoal': Math.round(100*percent),
'percentToStrechGoalCss': Math.round(145*percent),
'strechGoal': accounting.formatMoney(strechGoal, {precision:0, symbol:settings.kickstarter.currency})
});
}
})
});
app.get('/:any?.png', kickstarter_update.webshotRoute(settings.prefix, settings.webshot));
if(settings.pushToS3) {
setInterval(kickstarter_update.webshotToS3({
Bucket: settings.Bucket,
prefix: settings.prefix,
accessKeyId: settings.accessKeyId,
secretAccessKey: settings.secretAccessKey,
maxAgeInSeconds: settings.maxAgeInSeconds,
webshot: settings.webshot
}), settings.checkInterval);
}
app.listen(settings.port);