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
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user