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:
कारतोफ्फेलस्क्रिप्ट™
2023-12-27 11:50:43 +01:00
committed by GitHub
parent 518a99e528
commit f69ddcd796
51 changed files with 209 additions and 522 deletions

View File

@@ -7,6 +7,7 @@ import {
UpdateDateColumn,
} from 'typeorm';
import config from '@/config';
import type { Class } from 'n8n-core';
import { generateNanoId } from '../utils/generators';
const dbType = config.getEnv('database.type');
@@ -27,9 +28,7 @@ const tsColumnOptions: ColumnOptions = {
type: datetimeColumnType,
};
type Constructor<T> = new (...args: any[]) => T;
function mixinStringId<T extends Constructor<{}>>(base: T) {
function mixinStringId<T extends Class<{}, any[]>>(base: T) {
class Derived extends base {
@PrimaryColumn('varchar')
id: string;
@@ -44,7 +43,7 @@ function mixinStringId<T extends Constructor<{}>>(base: T) {
return Derived;
}
function mixinTimestamps<T extends Constructor<{}>>(base: T) {
function mixinTimestamps<T extends Class<{}, any[]>>(base: T) {
class Derived extends base {
@CreateDateColumn(tsColumnOptions)
createdAt: Date;