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
@@ -1,12 +1,12 @@
|
||||
import type { Request } from 'express';
|
||||
import { ICredentialTypes } from 'n8n-workflow';
|
||||
import { join } from 'path';
|
||||
import { access } from 'fs/promises';
|
||||
import { Authorized, Get, RestController } from '@/decorators';
|
||||
import { Config } from '@/config';
|
||||
import config from '@/config';
|
||||
import { NODES_BASE_DIR } from '@/constants';
|
||||
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
||||
import { InternalServerError } from '@/errors/response-errors/internal-server.error';
|
||||
import { CredentialTypes } from '@/CredentialTypes';
|
||||
|
||||
export const CREDENTIAL_TRANSLATIONS_DIR = 'n8n-nodes-base/dist/credentials/translations';
|
||||
export const NODE_HEADERS_PATH = join(NODES_BASE_DIR, 'dist/nodes/headers');
|
||||
@@ -18,10 +18,7 @@ export declare namespace TranslationRequest {
|
||||
@Authorized()
|
||||
@RestController('/')
|
||||
export class TranslationController {
|
||||
constructor(
|
||||
private config: Config,
|
||||
private credentialTypes: ICredentialTypes,
|
||||
) {}
|
||||
constructor(private readonly credentialTypes: CredentialTypes) {}
|
||||
|
||||
@Get('/credential-translation')
|
||||
async getCredentialTranslation(req: TranslationRequest.Credential) {
|
||||
@@ -30,7 +27,7 @@ export class TranslationController {
|
||||
if (!this.credentialTypes.recognizes(credentialType))
|
||||
throw new BadRequestError(`Invalid Credential type: "${credentialType}"`);
|
||||
|
||||
const defaultLocale = this.config.getEnv('defaultLocale');
|
||||
const defaultLocale = config.getEnv('defaultLocale');
|
||||
const translationPath = join(
|
||||
CREDENTIAL_TRANSLATIONS_DIR,
|
||||
defaultLocale,
|
||||
|
||||
Reference in New Issue
Block a user