mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 10:31:15 +00:00
refactor(core): Use an IoC container to manage singleton classes [Part-2] (no-changelog) (#5690)
* use typedi for UserManagementMailer * use typedi for SamlService * fix typos * use typedi for Queue * use typedi for License * convert some more code to use typedi
This commit is contained in:
committed by
GitHub
parent
c07f838ce6
commit
9bd7529193
@@ -2,13 +2,9 @@ import { existsSync } from 'fs';
|
||||
import { readFile } from 'fs/promises';
|
||||
import Handlebars from 'handlebars';
|
||||
import { join as pathJoin } from 'path';
|
||||
import { Service } from 'typedi';
|
||||
import config from '@/config';
|
||||
import type {
|
||||
InviteEmailData,
|
||||
PasswordResetData,
|
||||
SendEmailResult,
|
||||
UserManagementMailerImplementation,
|
||||
} from './Interfaces';
|
||||
import type { InviteEmailData, PasswordResetData, SendEmailResult } from './Interfaces';
|
||||
import { NodeMailer } from './NodeMailer';
|
||||
|
||||
type Template = HandlebarsTemplateDelegate<unknown>;
|
||||
@@ -36,8 +32,9 @@ async function getTemplate(
|
||||
return template;
|
||||
}
|
||||
|
||||
@Service()
|
||||
export class UserManagementMailer {
|
||||
private mailer: UserManagementMailerImplementation | undefined;
|
||||
private mailer: NodeMailer | undefined;
|
||||
|
||||
constructor() {
|
||||
// Other implementations can be used in the future.
|
||||
@@ -81,12 +78,3 @@ export class UserManagementMailer {
|
||||
return result ?? { emailSent: false };
|
||||
}
|
||||
}
|
||||
|
||||
let mailerInstance: UserManagementMailer | undefined;
|
||||
|
||||
export function getInstance(): UserManagementMailer {
|
||||
if (mailerInstance === undefined) {
|
||||
mailerInstance = new UserManagementMailer();
|
||||
}
|
||||
return mailerInstance;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user