From 2073b0fc83913c754f9212358f6ee6d21cb97d57 Mon Sep 17 00:00:00 2001 From: Tomi Turtiainen <10324676+tomi@users.noreply.github.com> Date: Mon, 12 Aug 2024 15:14:31 +0300 Subject: [PATCH 1/2] refactor(core): Rename ActiveWebhooks to LiveWebhooks As per discussed in https://n8nio.slack.com/archives/C069HS026UF/p1722857236311959 --- packages/cli/src/AbstractServer.ts | 12 ++++++------ .../webhooks/{ActiveWebhooks.ts => LiveWebhooks.ts} | 4 ++-- packages/cli/test/integration/webhooks.test.ts | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) rename packages/cli/src/webhooks/{ActiveWebhooks.ts => LiveWebhooks.ts} (97%) diff --git a/packages/cli/src/AbstractServer.ts b/packages/cli/src/AbstractServer.ts index 676db8db0aa03..93ecb500c698c 100644 --- a/packages/cli/src/AbstractServer.ts +++ b/packages/cli/src/AbstractServer.ts @@ -17,7 +17,7 @@ import { WaitingForms } from '@/WaitingForms'; import { TestWebhooks } from '@/webhooks/TestWebhooks'; import { WaitingWebhooks } from '@/webhooks/WaitingWebhooks'; import { createWebhookHandlerFor } from '@/webhooks/WebhookRequestHandler'; -import { ActiveWebhooks } from '@/webhooks/ActiveWebhooks'; +import { LiveWebhooks } from '@/webhooks/LiveWebhooks'; import { generateHostInstanceId } from './databases/utils/generators'; import { Logger } from '@/Logger'; import { ServiceUnavailableError } from './errors/response-errors/service-unavailable.error'; @@ -181,12 +181,12 @@ export abstract class AbstractServer { // Setup webhook handlers before bodyParser, to let the Webhook node handle binary data in requests if (this.webhooksEnabled) { - const activeWebhooksRequestHandler = createWebhookHandlerFor(Container.get(ActiveWebhooks)); - // Register a handler for active forms - this.app.all(`/${this.endpointForm}/:path(*)`, activeWebhooksRequestHandler); + const liveWebhooksRequestHandler = createWebhookHandlerFor(Container.get(LiveWebhooks)); + // Register a handler for live forms + this.app.all(`/${this.endpointForm}/:path(*)`, liveWebhooksRequestHandler); - // Register a handler for active webhooks - this.app.all(`/${this.endpointWebhook}/:path(*)`, activeWebhooksRequestHandler); + // Register a handler for live webhooks + this.app.all(`/${this.endpointWebhook}/:path(*)`, liveWebhooksRequestHandler); // Register a handler for waiting forms this.app.all( diff --git a/packages/cli/src/webhooks/ActiveWebhooks.ts b/packages/cli/src/webhooks/LiveWebhooks.ts similarity index 97% rename from packages/cli/src/webhooks/ActiveWebhooks.ts rename to packages/cli/src/webhooks/LiveWebhooks.ts index c18f949b88cca..3d66b7ee7f796 100644 --- a/packages/cli/src/webhooks/ActiveWebhooks.ts +++ b/packages/cli/src/webhooks/LiveWebhooks.ts @@ -20,12 +20,12 @@ import * as WebhookHelpers from '@/webhooks/WebhookHelpers'; import { WorkflowStaticDataService } from '@/workflows/workflowStaticData.service'; /** - * Service for handling the execution of production webhooks, i.e. webhooks + * Service for handling the execution of live webhooks, i.e. webhooks * that belong to activated workflows and use the production URL * (https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.webhook/#webhook-urls) */ @Service() -export class ActiveWebhooks implements IWebhookManager { +export class LiveWebhooks implements IWebhookManager { constructor( private readonly logger: Logger, private readonly nodeTypes: NodeTypes, diff --git a/packages/cli/test/integration/webhooks.test.ts b/packages/cli/test/integration/webhooks.test.ts index 44bc32c1b5a62..bbf53ba1e7dae 100644 --- a/packages/cli/test/integration/webhooks.test.ts +++ b/packages/cli/test/integration/webhooks.test.ts @@ -3,7 +3,7 @@ import { agent as testAgent } from 'supertest'; import { mock } from 'jest-mock-extended'; import { AbstractServer } from '@/AbstractServer'; -import { ActiveWebhooks } from '@/webhooks/ActiveWebhooks'; +import { LiveWebhooks } from '@/webhooks/LiveWebhooks'; import { ExternalHooks } from '@/ExternalHooks'; import { TestWebhooks } from '@/webhooks/TestWebhooks'; import { WaitingWebhooks } from '@/webhooks/WaitingWebhooks'; @@ -21,7 +21,7 @@ describe('WebhookServer', () => { describe('CORS', () => { const corsOrigin = 'https://example.com'; - const activeWebhooks = mockInstance(ActiveWebhooks); + const activeWebhooks = mockInstance(LiveWebhooks); const testWebhooks = mockInstance(TestWebhooks); mockInstance(WaitingWebhooks); mockInstance(WaitingForms); From 518a14577a0b68caaaadc6f808c1fc08f92448b7 Mon Sep 17 00:00:00 2001 From: Tomi Turtiainen <10324676+tomi@users.noreply.github.com> Date: Mon, 12 Aug 2024 15:30:13 +0300 Subject: [PATCH 2/2] refactor: Rename variable --- packages/cli/test/integration/webhooks.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cli/test/integration/webhooks.test.ts b/packages/cli/test/integration/webhooks.test.ts index bbf53ba1e7dae..a729f9515818a 100644 --- a/packages/cli/test/integration/webhooks.test.ts +++ b/packages/cli/test/integration/webhooks.test.ts @@ -21,7 +21,7 @@ describe('WebhookServer', () => { describe('CORS', () => { const corsOrigin = 'https://example.com'; - const activeWebhooks = mockInstance(LiveWebhooks); + const liveWebhooks = mockInstance(LiveWebhooks); const testWebhooks = mockInstance(TestWebhooks); mockInstance(WaitingWebhooks); mockInstance(WaitingForms); @@ -35,7 +35,7 @@ describe('WebhookServer', () => { }); const tests = [ - ['webhook', activeWebhooks], + ['webhook', liveWebhooks], ['webhookTest', testWebhooks], // TODO: enable webhookWaiting & waitingForms after CORS support is added // ['webhookWaiting', waitingWebhooks],