mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
feat(Webhook Node): Setting to enable multiple outputs/methods (#9086)
Co-authored-by: Giulio Andreini <andreini@netseven.it>
This commit is contained in:
@@ -50,22 +50,34 @@ export const getResponseData = (parameters: WebhookParameters) => {
|
||||
};
|
||||
|
||||
export const configuredOutputs = (parameters: WebhookParameters) => {
|
||||
const httpMethod = parameters.httpMethod;
|
||||
const httpMethod = parameters.httpMethod as string | string[];
|
||||
|
||||
return [
|
||||
{
|
||||
if (!Array.isArray(httpMethod))
|
||||
return [
|
||||
{
|
||||
type: `${NodeConnectionType.Main}`,
|
||||
displayName: httpMethod,
|
||||
},
|
||||
];
|
||||
|
||||
const outputs = httpMethod.map((method) => {
|
||||
return {
|
||||
type: `${NodeConnectionType.Main}`,
|
||||
displayName: httpMethod,
|
||||
},
|
||||
];
|
||||
displayName: method,
|
||||
};
|
||||
});
|
||||
|
||||
return outputs;
|
||||
};
|
||||
|
||||
export const setupOutputConnection = (
|
||||
ctx: IWebhookFunctions,
|
||||
method: string,
|
||||
additionalData: {
|
||||
jwtPayload?: IDataObject;
|
||||
},
|
||||
) => {
|
||||
const httpMethod = ctx.getNodeParameter('httpMethod', []) as string[] | string;
|
||||
let webhookUrl = ctx.getNodeWebhookUrl('default') as string;
|
||||
const executionMode = ctx.getMode() === 'manual' ? 'test' : 'production';
|
||||
|
||||
@@ -73,13 +85,29 @@ export const setupOutputConnection = (
|
||||
webhookUrl = webhookUrl.replace('/webhook/', '/webhook-test/');
|
||||
}
|
||||
|
||||
// multi methods could be set in settings of node, so we need to check if it's an array
|
||||
if (!Array.isArray(httpMethod)) {
|
||||
return (outputData: INodeExecutionData): INodeExecutionData[][] => {
|
||||
outputData.json.webhookUrl = webhookUrl;
|
||||
outputData.json.executionMode = executionMode;
|
||||
if (additionalData?.jwtPayload) {
|
||||
outputData.json.jwtPayload = additionalData.jwtPayload;
|
||||
}
|
||||
return [[outputData]];
|
||||
};
|
||||
}
|
||||
|
||||
const outputIndex = httpMethod.indexOf(method.toUpperCase());
|
||||
const outputs: INodeExecutionData[][] = httpMethod.map(() => []);
|
||||
|
||||
return (outputData: INodeExecutionData): INodeExecutionData[][] => {
|
||||
outputData.json.webhookUrl = webhookUrl;
|
||||
outputData.json.executionMode = executionMode;
|
||||
if (additionalData?.jwtPayload) {
|
||||
outputData.json.jwtPayload = additionalData.jwtPayload;
|
||||
}
|
||||
return [[outputData]];
|
||||
outputs[outputIndex] = [outputData];
|
||||
return outputs;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user