feat(Webhook Node): Setting to enable multiple outputs/methods (#9086)

Co-authored-by: Giulio Andreini <andreini@netseven.it>
This commit is contained in:
Michael Kret
2024-04-24 08:46:16 +03:00
committed by GitHub
parent f6142ff275
commit 2bf0a3933e
7 changed files with 153 additions and 29 deletions

View File

@@ -74,7 +74,60 @@ export class Webhook extends Node {
credentials: credentialsProperty(this.authPropertyName),
webhooks: [defaultWebhookDescription],
properties: [
httpMethodsProperty,
{
displayName: 'Allow Multiple HTTP Methods',
name: 'multipleMethods',
type: 'boolean',
default: false,
isNodeSetting: true,
description: 'Whether to allow the webhook to listen for multiple HTTP methods',
},
{
...httpMethodsProperty,
displayOptions: {
show: {
multipleMethods: [false],
},
},
},
{
displayName: 'HTTP Methods',
name: 'httpMethod',
type: 'multiOptions',
options: [
{
name: 'DELETE',
value: 'DELETE',
},
{
name: 'GET',
value: 'GET',
},
{
name: 'HEAD',
value: 'HEAD',
},
{
name: 'PATCH',
value: 'PATCH',
},
{
name: 'POST',
value: 'POST',
},
{
name: 'PUT',
value: 'PUT',
},
],
default: ['GET', 'POST'],
description: 'The HTTP methods to listen to',
displayOptions: {
show: {
multipleMethods: [true],
},
},
},
{
displayName: 'Path',
name: 'path',
@@ -144,6 +197,7 @@ export class Webhook extends Node {
};
const req = context.getRequestObject();
const resp = context.getResponseObject();
const requestMethod = context.getRequestObject().method;
if (!isIpWhitelisted(options.ipWhitelist, req.ips, req.ip)) {
resp.writeHead(403);
@@ -165,7 +219,7 @@ export class Webhook extends Node {
throw error;
}
const prepareOutput = setupOutputConnection(context, {
const prepareOutput = setupOutputConnection(context, requestMethod, {
jwtPayload: validationData,
});