-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
36 lines (29 loc) · 1.05 KB
/
app.js
File metadata and controls
36 lines (29 loc) · 1.05 KB
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
'use strict'
var express = require('express')
var bodyParser = require('body-parser')
var xhub = require('express-x-hub')
var neo4j = require('neo4j')
var EventModel = require('./models/event')
var EventRouteHandlers = require('./routes/events')
// Event is a singleton; save it's database connection
EventModel.setDatabaseConnection (new neo4j.GraphDatabase ({
url: process.env['NEO4J_URL'] || process.env['GRAPHENEDB_URL'] ||
'http://neo4j:neo4j@localhost:7474',
auth: process.env['NEO4J_AUTH'],
}))
var app = express ()
var port = 3000
// Middleware to validate Github X-Hub-Signature
app.use (xhub ( { algorithm: 'sha1', secret: process.env.X_HUB_SECRET } ))
// Middleware to parse JSON requests
app.use (bodyParser.json ())
app.use (bodyParser.urlencoded ( { extended: true } ))
// Github Webhook handler. EventRouteHandlers is a singleton
app.post ('/event', EventRouteHandlers.create)
app.listen (port, (error) => {
if (error) {
console.error (error)
} else {
console.info ("==> 🌎 Listening on port %s.", port)
}
})