refactor(core): Move all base URLs to UrlService (no-changelog) (#8141)

This change kept coming up in #6713, #7773, and #8135. 
So this PR moves the existing code without actually changing anything,
to help get rid of some of the circular dependencies.


## Review / Merge checklist
- [x] PR title and summary are descriptive.
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-12-22 15:19:50 +01:00
committed by GitHub
parent 517b050d0a
commit baee47a276
16 changed files with 93 additions and 85 deletions

View File

@@ -15,7 +15,6 @@ import config from '@/config';
import { ActiveExecutions } from '@/ActiveExecutions';
import { ActiveWorkflowRunner } from '@/ActiveWorkflowRunner';
import * as GenericHelpers from '@/GenericHelpers';
import { Server } from '@/Server';
import { EDITOR_UI_DIST_DIR, LICENSE_FEATURES } from '@/constants';
import { eventBus } from '@/eventbus';
@@ -27,6 +26,7 @@ import { SingleMainSetup } from '@/services/orchestration/main/SingleMainSetup';
import { OrchestrationHandlerMainService } from '@/services/orchestration/main/orchestration.handler.main.service';
import { PruningService } from '@/services/pruning.service';
import { MultiMainSetup } from '@/services/orchestration/main/MultiMainSetup.ee';
import { UrlService } from '@/services/url.service';
import { SettingsRepository } from '@db/repositories/settings.repository';
import { ExecutionRepository } from '@db/repositories/execution.repository';
import { FeatureNotLicensedError } from '@/errors/feature-not-licensed.error';
@@ -77,7 +77,7 @@ export class Start extends BaseCommand {
* Opens the UI in browser
*/
private openBrowser() {
const editorUrl = GenericHelpers.getBaseUrl();
const editorUrl = Container.get(UrlService).baseUrl;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
open(editorUrl, { wait: true }).catch((error: Error) => {
@@ -321,7 +321,7 @@ export class Start extends BaseCommand {
// Start to get active workflows and run their triggers
await this.activeWorkflowRunner.init();
const editorUrl = GenericHelpers.getBaseUrl();
const editorUrl = Container.get(UrlService).baseUrl;
this.log(`\nEditor is now accessible via:\n${editorUrl}`);
// Allow to open n8n editor by pressing "o"