-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
52 lines (30 loc) · 961 Bytes
/
test.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
46
47
48
49
var createApp = require('github-app');
var app = createApp({
id: process.env.APP_ID,
cert: require('fs').readFileSync('docloop.2017-09-13.private-key.pem')
});
var createHandler = require('github-webhook-handler');
var handler = createHandler({
path: '/',
secret: process.env.DOCLOOP_APP_TOKEN
})
handler.on('issues', function (event) {
if (event.payload.action === 'opened') {
var installation = event.payload.installation.id;
app.asInstallation(installation).then(function (github) {
github.issues.createComment({
owner: event.payload.repository.owner.login,
repo: event.payload.repository.name,
number: event.payload.issue.number,
body: 'Welcome to the robot uprising.'
});
});
}
});
var http = require('http');
http.createServer(function (req, res) {
handler(req, res, function (err) {
res.statusCode = 404
res.end('no such location')
});
}).listen(7777)