n8n
Version:
n8n Workflow Automation Tool
34 lines (33 loc) • 1.31 kB
TypeScript
import type { Request, Response } from 'express';
import type { IDataObject, IHttpRequestMethods } from 'n8n-workflow';
import type { ExpectedWebhookNodeType } from './node-type-matcher';
import type { WebhookResponse } from './webhook-response';
export type WebhookOptionsRequest = Request & {
method: 'OPTIONS';
};
export type WebhookRequest = Request<{
path: string;
}> & {
method: IHttpRequestMethods;
params: Record<string, string>;
};
export type WaitingWebhookRequest = WebhookRequest & {
params: Pick<WebhookRequest['params'], 'path'> & {
suffix?: string;
};
};
export interface WebhookAccessControlOptions {
allowedOrigins?: string;
}
export interface IWebhookManager {
getWebhookMethods?: (path: string) => Promise<IHttpRequestMethods[]>;
findAccessControlOptions: (path: string, httpMethod: IHttpRequestMethods) => Promise<WebhookAccessControlOptions | undefined>;
executeWebhook(req: WebhookRequest, res: Response, expectedNodeType?: ExpectedWebhookNodeType): Promise<IWebhookResponseCallbackData | WebhookResponse>;
}
export interface IWebhookResponseCallbackData {
data?: IDataObject | IDataObject[];
headers?: object;
noWebhookResponse?: boolean;
responseCode?: number;
}
export type Method = NonNullable<IHttpRequestMethods>;