-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
38 lines (30 loc) · 966 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
36
37
38
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var actions = require('./lib/actions');
app.use(bodyParser.json());
app.set('port', (process.env.PORT || 5000));
app.post('/callback', function (req, res) {
var update = req.body.action;
var updateActions = {
'createCard': ['updateCardNameWithId'],
'updateCard': ['updateCardEstimation']
};
console.log('[Trello] Update of type: ' + update.type);
var actionsRequested = updateActions[update.type];
if (actionsRequested) {
console.log('actions requested: ' + actionsRequested);
actionsRequested.forEach(function (action) {
if (typeof actions[action] === 'function') {
actions[action](update);
}
});
}
res.send('OK');
});
app.get('/', function (req, res) {
res.send('Trello Scrum Server');
});
app.listen(app.get('port'), function() {
console.log('Node app is running on port', app.get('port'));
});