refactor(core): Use Dependency Injection for all Controller classes (no-changelog) (#8146)
## Review / Merge checklist - [x] PR title and summary are descriptive
This commit is contained in:
committed by
GitHub
parent
518a99e528
commit
f69ddcd796
@@ -10,7 +10,6 @@ export const SOURCE_CONTROL_SSH_FOLDER = 'ssh';
|
||||
export const SOURCE_CONTROL_SSH_KEY_NAME = 'key';
|
||||
export const SOURCE_CONTROL_DEFAULT_BRANCH = 'main';
|
||||
export const SOURCE_CONTROL_ORIGIN = 'origin';
|
||||
export const SOURCE_CONTROL_API_ROOT = 'source-control';
|
||||
export const SOURCE_CONTROL_README = `
|
||||
# n8n Source Control
|
||||
`;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { Container, Service } from 'typedi';
|
||||
import type { PullResult } from 'simple-git';
|
||||
import express from 'express';
|
||||
import { Authorized, Get, Post, Patch, RestController, RequireGlobalScope } from '@/decorators';
|
||||
@@ -11,20 +10,20 @@ import { SourceControlRequest } from './types/requests';
|
||||
import { SourceControlPreferencesService } from './sourceControlPreferences.service.ee';
|
||||
import type { SourceControlPreferences } from './types/sourceControlPreferences';
|
||||
import type { SourceControlledFile } from './types/sourceControlledFile';
|
||||
import { SOURCE_CONTROL_API_ROOT, SOURCE_CONTROL_DEFAULT_BRANCH } from './constants';
|
||||
import { SOURCE_CONTROL_DEFAULT_BRANCH } from './constants';
|
||||
import type { ImportResult } from './types/importResult';
|
||||
import { InternalHooks } from '../../InternalHooks';
|
||||
import { InternalHooks } from '@/InternalHooks';
|
||||
import { getRepoType } from './sourceControlHelper.ee';
|
||||
import { SourceControlGetStatus } from './types/sourceControlGetStatus';
|
||||
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
||||
|
||||
@Service()
|
||||
@Authorized()
|
||||
@RestController(`/${SOURCE_CONTROL_API_ROOT}`)
|
||||
@RestController('/source-control')
|
||||
export class SourceControlController {
|
||||
constructor(
|
||||
private sourceControlService: SourceControlService,
|
||||
private sourceControlPreferencesService: SourceControlPreferencesService,
|
||||
private readonly sourceControlService: SourceControlService,
|
||||
private readonly sourceControlPreferencesService: SourceControlPreferencesService,
|
||||
private readonly internalHooks: InternalHooks,
|
||||
) {}
|
||||
|
||||
@Authorized('none')
|
||||
@@ -85,7 +84,7 @@ export class SourceControlController {
|
||||
const resultingPreferences = this.sourceControlPreferencesService.getPreferences();
|
||||
// #region Tracking Information
|
||||
// located in controller so as to not call this multiple times when updating preferences
|
||||
void Container.get(InternalHooks).onSourceControlSettingsUpdated({
|
||||
void this.internalHooks.onSourceControlSettingsUpdated({
|
||||
branch_name: resultingPreferences.branchName,
|
||||
connected: resultingPreferences.connected,
|
||||
read_only_instance: resultingPreferences.branchReadOnly,
|
||||
@@ -130,7 +129,7 @@ export class SourceControlController {
|
||||
}
|
||||
await this.sourceControlService.init();
|
||||
const resultingPreferences = this.sourceControlPreferencesService.getPreferences();
|
||||
void Container.get(InternalHooks).onSourceControlSettingsUpdated({
|
||||
void this.internalHooks.onSourceControlSettingsUpdated({
|
||||
branch_name: resultingPreferences.branchName,
|
||||
connected: resultingPreferences.connected,
|
||||
read_only_instance: resultingPreferences.branchReadOnly,
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import { Service } from 'typedi';
|
||||
|
||||
import { VariablesRequest } from '@/requests';
|
||||
import {
|
||||
Authorized,
|
||||
@@ -17,11 +15,10 @@ import { NotFoundError } from '@/errors/response-errors/not-found.error';
|
||||
import { VariableValidationError } from '@/errors/variable-validation.error';
|
||||
import { VariableCountLimitReachedError } from '@/errors/variable-count-limit-reached.error';
|
||||
|
||||
@Service()
|
||||
@Authorized()
|
||||
@RestController('/variables')
|
||||
export class VariablesController {
|
||||
constructor(private variablesService: VariablesService) {}
|
||||
constructor(private readonly variablesService: VariablesService) {}
|
||||
|
||||
@Get('/')
|
||||
@RequireGlobalScope('variable:list')
|
||||
|
||||
Reference in New Issue
Block a user