app -> ts
This commit is contained in:
1 parent
147eff3ede
commit
2a8d2cb06a
10 files changed
+152
-89
No files matched your search
@@ -10,26 +10,35 @@ import StatusPageController from "../controllers/statusPageController.js";
|
||||
import NotificationController from "../controllers/notificationController.js";
|
||||
import DiagnosticController from "../controllers/diagnosticController.js";
|
||||
import IncidentController from "../controllers/incidentController.js";
|
||||
import type { InitializedSerivces } from "@/config/services.js";
|
||||
export const initializeControllers = (services: InitializedSerivces) => {
|
||||
const controllers: Record<string, any> = {};
|
||||
import type { InitializedServices } from "@/config/services.js";
|
||||
|
||||
controllers.authController = new AuthController(services.userService);
|
||||
|
||||
controllers.monitorController = new MonitorController(services.monitorService);
|
||||
|
||||
controllers.settingsController = new SettingsController(services.settingsService, services.emailService, services.db);
|
||||
controllers.checkController = new CheckController(services.checkService);
|
||||
controllers.inviteController = new InviteController(services.inviteService);
|
||||
|
||||
controllers.maintenanceWindowController = new MaintenanceWindowController(services.maintenanceWindowService);
|
||||
controllers.queueController = new QueueController(services.jobQueue);
|
||||
controllers.logController = new LogController(services.logger);
|
||||
controllers.statusPageController = new StatusPageController(services.db);
|
||||
controllers.notificationController = new NotificationController(services.notificationsService, services.db, services.monitorsRepository);
|
||||
controllers.diagnosticController = new DiagnosticController(services.diagnosticService);
|
||||
|
||||
controllers.incidentController = new IncidentController(services.incidentService);
|
||||
|
||||
return controllers;
|
||||
export interface InitializedControllers {
|
||||
authController: AuthController;
|
||||
monitorController: MonitorController;
|
||||
settingsController: SettingsController;
|
||||
checkController: CheckController;
|
||||
inviteController: InviteController;
|
||||
maintenanceWindowController: MaintenanceWindowController;
|
||||
queueController: QueueController;
|
||||
logController: LogController;
|
||||
statusPageController: StatusPageController;
|
||||
notificationController: NotificationController;
|
||||
diagnosticController: DiagnosticController;
|
||||
incidentController: IncidentController;
|
||||
}
|
||||
export const initializeControllers = (services: InitializedServices): InitializedControllers => {
|
||||
return {
|
||||
authController: new AuthController(services.userService),
|
||||
monitorController: new MonitorController(services.monitorService),
|
||||
settingsController: new SettingsController(services.settingsService, services.emailService, services.db),
|
||||
checkController: new CheckController(services.checkService),
|
||||
inviteController: new InviteController(services.inviteService),
|
||||
maintenanceWindowController: new MaintenanceWindowController(services.maintenanceWindowService),
|
||||
queueController: new QueueController(services.jobQueue),
|
||||
logController: new LogController(services.logger),
|
||||
statusPageController: new StatusPageController(services.db),
|
||||
notificationController: new NotificationController(services.notificationsService, services.db, services.monitorsRepository),
|
||||
diagnosticController: new DiagnosticController(services.diagnosticService),
|
||||
incidentController: new IncidentController(services.incidentService),
|
||||
};
|
||||
};
|
||||
@@ -1,25 +0,0 @@
|
||||
import dotenv from "dotenv";
|
||||
|
||||
export interface IEevConfig {
|
||||
NODE_ENV: string;
|
||||
JWT_SECRET: string;
|
||||
PORT: number;
|
||||
PAGESPEED_API_KEY: string;
|
||||
SMTP_HOST: string;
|
||||
SMTP_PORT: number;
|
||||
SMTP_USER: string;
|
||||
SMTP_PASS: string;
|
||||
}
|
||||
|
||||
dotenv.config();
|
||||
|
||||
export const config: IEevConfig = {
|
||||
NODE_ENV: process.env.NODE_ENV || "development",
|
||||
JWT_SECRET: process.env.JWT_SECRET || "your_jwt_secret",
|
||||
PORT: process.env.PORT ? parseInt(process.env.PORT, 10) : 3000,
|
||||
PAGESPEED_API_KEY: process.env.PAGESPEED_API_KEY || "",
|
||||
SMTP_HOST: process.env.SMTP_HOST || "smtp.example.com",
|
||||
SMTP_PORT: process.env.SMTP_PORT ? parseInt(process.env.SMTP_PORT, 10) : 587,
|
||||
SMTP_USER: process.env.SMTP_USER || "user@example.com",
|
||||
SMTP_PASS: process.env.SMTP_PASS || "your_smtp_password",
|
||||
};
|
||||
@@ -92,8 +92,10 @@ import {
|
||||
INotificationsRepository,
|
||||
IIncidentsRepository,
|
||||
} from "@/repositories/index.js";
|
||||
import { ILogger } from "@/utils/logger.js";
|
||||
import { EnvConfig } from "@/service/system/settingsService.js";
|
||||
|
||||
export type InitializedSerivces = {
|
||||
export type InitializedServices = {
|
||||
//v1
|
||||
settingsService: any;
|
||||
translationService: any;
|
||||
@@ -132,10 +134,10 @@ export const initializeServices = async ({
|
||||
envSettings,
|
||||
settingsService,
|
||||
}: {
|
||||
logger: any;
|
||||
envSettings: any;
|
||||
logger: ILogger;
|
||||
envSettings: EnvConfig;
|
||||
settingsService: any;
|
||||
}): Promise<InitializedSerivces> => {
|
||||
}): Promise<InitializedServices> => {
|
||||
const translationService = new TranslationService(logger);
|
||||
await translationService.initialize();
|
||||
|
||||
@@ -205,7 +207,7 @@ export const initializeServices = async ({
|
||||
checksRepository,
|
||||
});
|
||||
|
||||
const bufferService = new BufferService({ logger, checkService });
|
||||
const bufferService = new BufferService({ logger, checkService, settingsService });
|
||||
|
||||
const statusService = new StatusService({ db, logger, buffer: bufferService, monitorsRepository });
|
||||
|
||||
|
||||
Reference in new issue
Block a user