-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
44 lines (34 loc) · 1.23 KB
/
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
39
40
41
42
43
44
'use strict'
const Hapi = require('hapi')
, Boom = require('boom')
, Request = require('request')
let server = new Hapi.Server()
server.connection({
port: process.env.PORT || 3000
})
server.route({
method: 'GET',
path: '/',
handler(request, reply) {
reply('Hello, hello!')
}
})
server.route({
method: 'POST',
path: '/',
handler(request, reply) {
// if (request.headers['x-hub-signature'] !== process.env.GH_SECRET)
// return reply(Boom.unauthorized('Not so fast!'))
if (request.headers['x-github-event'] !== 'issues')
return reply('🙈 ')
let response = {
channel: process.env.SLACK_CHANNEL,
username: "JS Belgrade CFP",
icon_url: "https://raw.githubusercontent.com/jsbelgrade/assets/master/logo/JSBelgrade-logo-512.png",
text: `*<${request.payload.issue.user.html_url}|${request.payload.issue.user.login}>* submitted a new talk proposal: "${request.payload.issue.title}". Check it here: <${request.payload.issue.html_url}|${request.payload.issue.html_url}>.`
}
Request.post(process.env.SLACK_URL).form({payload: JSON.stringify(response)})
reply('Thanks Github!')
}
})
server.start(() => console.log(`Server running at: ${server.info.uri}`))