2024-05-15 10:10:41 +02:00
|
|
|
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 {
|
2026-04-28 12:02:58 +00:00
|
|
|
public projectinfo!: plugins.projectinfo.ProjectinfoNpm;
|
|
|
|
|
public typedrouter: plugins.typedrequest.TypedRouter = new plugins.typedrequest.TypedRouter();
|
2024-05-15 10:10:41 +02:00
|
|
|
public coreflowConnector: CoreflowConnector;
|
|
|
|
|
public taskmanager: CoretrafficTaskManager;
|
2026-04-28 12:02:58 +00:00
|
|
|
public smartProxy: plugins.smartproxy.SmartProxy;
|
2024-05-15 10:10:41 +02:00
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
|
this.coreflowConnector = new CoreflowConnector(this);
|
|
|
|
|
this.taskmanager = new CoretrafficTaskManager(this);
|
2026-04-28 12:02:58 +00:00
|
|
|
this.smartProxy = new plugins.smartproxy.SmartProxy({
|
|
|
|
|
routes: [],
|
2024-05-15 10:10:41 +02:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* starts coretraffic
|
|
|
|
|
*/
|
|
|
|
|
public async start() {
|
2026-04-28 12:02:58 +00:00
|
|
|
this.projectinfo = await plugins.projectinfo.ProjectinfoNpm.create(paths.packageDir);
|
|
|
|
|
await this.smartProxy.start();
|
2024-05-15 10:10:41 +02:00
|
|
|
|
|
|
|
|
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');
|
2026-04-28 12:02:58 +00:00
|
|
|
await this.smartProxy.stop();
|
2024-05-15 10:10:41 +02:00
|
|
|
console.log('stopped smartproxy!');
|
2026-04-28 12:02:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public getDefaultResponseHeaders() {
|
|
|
|
|
return {
|
|
|
|
|
servezone_coretraffic_version: this.projectinfo?.version || 'unknown',
|
|
|
|
|
};
|
2024-05-15 10:10:41 +02:00
|
|
|
}
|
|
|
|
|
}
|