1
0
mirror of synced 2025-12-23 11:54:18 -05:00
Files
docs/middleware/contextualizers/webhooks.js
Vanessa Yuen 3df90fc9b8 Hello git history spelunker!
Are you looking for something? Here is all of the GitHub Docs history in one single commit. Enjoy! 🎉
2020-09-27 14:10:11 +02:00

21 lines
910 B
JavaScript

const path = require('path')
const { defaults } = require('lodash')
const webhookPayloads = require(path.join(process.cwd(), 'lib/webhooks'))
const { getOldVersionFromNewVersion } = require('../../lib/old-versions-utils')
module.exports = async (req, res, next) => {
// TODO need to update this to the new versions in coordination with the updater scripts
const currentOldVersion = process.env.FEATURE_NEW_VERSIONS
? getOldVersionFromNewVersion(req.context.currentVersion)
: req.context.currentVersion
const webhookPayloadsForCurrentVersion = webhookPayloads[currentOldVersion]
// if current version is GHE, include dotcom payloads in object so we can fall back to them if needed
req.context.webhookPayloadsForCurrentVersion = currentOldVersion === 'dotcom'
? webhookPayloadsForCurrentVersion
: defaults(webhookPayloadsForCurrentVersion, webhookPayloads.dotcom)
return next()
}