-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to inject parameters into webhook handlers #44
Comments
I will use the before-after-hook like we already do in const WebhooksApi = require('@octokit/webhooks')
const OctokitRest = require('@octokit/rest')
const webhooks = new WebhooksApi({
secret: 'mysecret'
})
webhooks.hook.before('webhook', (options) => {
options.client = new OctokitRest()
options.client.authenticate({
type: 'token',
token: process.env.GITHUB_TOKEN
})
})
webhook.on('foo.bar', options => {
// options.client is set now
})
webhooks.receive({id: '123', name: 'foo', payload: {action: 'bar'}})
// logs "Webhook received: foo.bar (id: 123)" |
The current |
It is. |
For the upcoming
octokit
we need to be able to inject a pre-authenticatedoctokit
client to the webhooks handler, see the Webhooks sectionThe
client
parameter in the code snippet above needs to be injected, it is not part of@octokit/webhooks
API. We need to be able to run code after a webhook is received, but before it is passed to the webhook handlers.One approach would be to implement middleware similar to what Express does: https://expressjs.com/en/guide/using-middleware.html. There is a related issue on Probot: probot/probot#598
An alternative would be to leverage the hook API that we already use in
@octokit/rest
and that will be part ofoctokit
: https://github.com/octokit/rest.js#hooks.The text was updated successfully, but these errors were encountered: