forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
load webhook versions at runtime instead of import-time (github#24788)
* load webhook versions at runtime instead of import-time * fix tests
- Loading branch information
Showing
3 changed files
with
39 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import { defaults } from 'lodash-es' | ||
import webhookPayloads from '../../lib/webhooks/index.js' | ||
import getWebhookPayloads from '../../lib/webhooks/index.js' | ||
import nonEnterpriseDefaultVersion from '../../lib/non-enterprise-default-version.js' | ||
import { allVersions } from '../../lib/all-versions.js' | ||
|
||
let webhookPayloads = null | ||
|
||
export default function webhooksContext(req, res, next) { | ||
const currentVersionObj = allVersions[req.context.currentVersion] | ||
// ignore requests to non-webhook reference paths | ||
|
@@ -11,6 +13,11 @@ export default function webhooksContext(req, res, next) { | |
return next() | ||
} | ||
|
||
// Idempotent for consecutive calls | ||
if (!webhookPayloads) { | ||
webhookPayloads = getWebhookPayloads() | ||
} | ||
|
||
// Get the name of the dir under lib/webhooks/static | ||
// For example, free-pro-team@latest corresponds to dotcom, | ||
// [email protected] corresponds to ghes-2.22, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters