Files
coretraffic/ts/coretraffic.classes.coretraffic.ts
T

55 lines
1.6 KiB
TypeScript
Raw Normal View History

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