-
Notifications
You must be signed in to change notification settings - Fork 11
/
index.js
29 lines (25 loc) · 873 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
const express = require('express'),
app = express(),
bodyParser = require('body-parser'),
port = process.env.PORT || 8080,
slack = require('./slack.js');
app.use(bodyParser.json());
app.post('/', function(req, res){
if (req.get('X-GitHub-Event') == 'watch'){
slack.sendMessage({
'text': '<' + req.body.sender.url + '|' + req.body.sender.login + '> ' + req.body.action + ' watching <' + req.body.repository.url + '|' + req.body.repository.name + '>'
});
}
if (req.get('X-GitHub-Event') == 'fork'){
slack.sendMessage({
'text': '<' + req.body.sender.url + '|' + req.body.sender.login + '> forked <' + req.body.repository.url + '|' + req.body.repository.name + '>',
});
}
res.sendStatus(200);
});
app.get('/', function(req, res){
res.send('hello!');
});
app.listen(port, function() {
console.log('running on http://localhost:' + port);
});