refactor(core): Make controller constructors consistent (no-changelog) (#7015)

This commit is contained in:
Iván Ovejero
2023-08-25 13:23:22 +02:00
committed by GitHub
parent 07d3633a05
commit 87cf1d9c1b
10 changed files with 145 additions and 270 deletions

View File

@@ -10,50 +10,25 @@ import {
} from '@/UserManagement/UserManagementHelper';
import { issueCookie } from '@/auth/jwt';
import { Response } from 'express';
import type { ILogger } from 'n8n-workflow';
import type { Config } from '@/config';
import { ILogger } from 'n8n-workflow';
import { Config } from '@/config';
import { OwnerRequest } from '@/requests';
import type { IDatabaseCollections, IInternalHooksClass } from '@/Interfaces';
import type { SettingsRepository } from '@db/repositories';
import { IInternalHooksClass } from '@/Interfaces';
import { SettingsRepository } from '@db/repositories';
import { PostHogClient } from '@/posthog';
import { UserService } from '@/services/user.service';
import Container from 'typedi';
import type { PostHogClient } from '@/posthog';
@Authorized(['global', 'owner'])
@RestController('/owner')
export class OwnerController {
private readonly config: Config;
private readonly logger: ILogger;
private readonly internalHooks: IInternalHooksClass;
private readonly userService: UserService;
private readonly settingsRepository: SettingsRepository;
private readonly postHog?: PostHogClient;
constructor({
config,
logger,
internalHooks,
repositories,
postHog,
}: {
config: Config;
logger: ILogger;
internalHooks: IInternalHooksClass;
repositories: Pick<IDatabaseCollections, 'Settings'>;
postHog?: PostHogClient;
}) {
this.config = config;
this.logger = logger;
this.internalHooks = internalHooks;
this.userService = Container.get(UserService);
this.settingsRepository = repositories.Settings;
this.postHog = postHog;
}
constructor(
private readonly config: Config,
private readonly logger: ILogger,
private readonly internalHooks: IInternalHooksClass,
private readonly settingsRepository: SettingsRepository,
private readonly userService: UserService,
private readonly postHog?: PostHogClient,
) {}
/**
* Promote a shell into the owner of the n8n instance,