Skip to content

Commit bb5034a

Browse files
authored
fix: Check that getRouter is defined before attempting to access it (#587)
1 parent 39d80e5 commit bb5034a

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

docs/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
CHANGELOG
22
=====================================
3+
| September 20, 2021 : fix: Check that getRouter is defined before attempting to access it `#587 <https://github.com/mergeability/mergeable/pull/587>`_
34
| August 26, 2021 : fix: Await GithubAPI topics response `#585 <https://github.com/mergeability/mergeable/pull/585>`_
45
| August 10, 2021 : feat: New labels API `#577 <https://github.com/mergeability/mergeable/pull/577>`_
56
| August 6, 2021 : feat: Add team assignment to request_review action `#574 <https://github.com/mergeability/mergeable/pull/574>`_

index.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@ const githubRateLimitEndpoint = require('./lib/utils/githubRateLimitEndpoint')
44
const prometheusMiddleware = require('express-prometheus-middleware')
55

66
module.exports = (robot, { getRouter }) => {
7-
const router = getRouter()
7+
if (getRouter !== undefined) {
8+
const router = getRouter()
89

9-
if (process.env.ENABLE_GITHUB_RATELIMIT_ENDPOINT === 'true') {
10-
// endpoint to fetch github given installation rate limit
11-
router.get('/github-ratelimit/:installationId', githubRateLimitEndpoint(robot))
12-
}
10+
if (process.env.ENABLE_GITHUB_RATELIMIT_ENDPOINT === 'true') {
11+
// endpoint to fetch github given installation rate limit
12+
router.get('/github-ratelimit/:installationId', githubRateLimitEndpoint(robot))
13+
}
1314

14-
if (process.env.ENABLE_METRICS_ENDPOINT === 'true') {
15-
// expose prometheus metrics
16-
router.use(prometheusMiddleware())
15+
if (process.env.ENABLE_METRICS_ENDPOINT === 'true') {
16+
// expose prometheus metrics
17+
router.use(prometheusMiddleware())
18+
}
1719
}
1820

1921
logger.init(robot.log)

0 commit comments

Comments
 (0)