import * as plugins from './coretraffic.plugins.js'; import * as paths from './coretraffic.paths.js' import { logger } from './coretraffic.logging.js'; import { CoreflowConnector } from './coretraffic.classes.coreflowconnector.js'; import { CoretrafficTaskManager } from './coretraffic.classes.taskmanager.js'; export interface ICoretrafficConfig { dockerDomainEnvName?: string; } export class CoreTraffic { public projectinfo!: plugins.projectinfo.ProjectinfoNpm; public typedrouter: plugins.typedrequest.TypedRouter = new plugins.typedrequest.TypedRouter(); public coreflowConnector: CoreflowConnector; public taskmanager: CoretrafficTaskManager; public smartProxy: plugins.smartproxy.SmartProxy; constructor() { this.coreflowConnector = new CoreflowConnector(this); this.taskmanager = new CoretrafficTaskManager(this); this.smartProxy = new plugins.smartproxy.SmartProxy({ routes: [], }); } /** * starts coretraffic */ public async start() { this.projectinfo = await plugins.projectinfo.ProjectinfoNpm.create(paths.packageDir); await this.smartProxy.start(); await this.taskmanager.start(); await this.coreflowConnector.start(); } /** * stops coretraffic */ public async stop() { await this.taskmanager.stop(); console.log('stopped taskmanager'); await this.coreflowConnector.stop(); console.log('stopped coreflowConnector'); await this.smartProxy.stop(); console.log('stopped smartproxy!'); } public getDefaultResponseHeaders() { return { servezone_coretraffic_version: this.projectinfo?.version || 'unknown', }; } }