Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 143
Expand file tree
/
Copy pathapp.js
More file actions
Latest commit
35 lines (25 loc) · 1020 Bytes
/
Copy pathapp.js
File metadata and controls
35 lines (25 loc) · 1020 Bytes
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
'use strict'
importexpressfrom'express'
importbodyParserfrom'body-parser'
importAsyncEventEmitterfrom'events-async'
importloggerfrom'./lib/logger.js'
importrequestLoggerfrom'./lib/request-logger.js'
importauthMiddlewarefrom'./lib/auth-middleware.js'
importgithubEventsfrom'./lib/github-events.js'
importjenkinsEventsfrom'./lib/jenkins-events.js'
constcaptureRaw=(req,res,buffer)=>{req.raw=buffer}
exportconstapp=express()
exportconstevents=newAsyncEventEmitter()
constlogsDir=process.env.LOGS_DIR||''
app.use(bodyParser.json({verify: captureRaw}))
if(logsDir){
app.use('/logs',authMiddleware,express.static(logsDir))
}
// Give each request a unique logger and avoid logging the GitHub webhook secret.
app.use(requestLogger(logger))
githubEvents(app,events)
jenkinsEvents(app,events)
app.use(functionlogUnhandledErrors(err,req,res,next){
logger.error(err,'Unhandled error while responding to incoming HTTP request')
res.status(500).end()
})