2024-02-16 13:28:40 +01:00
|
|
|
import * as plugins from './plugins.js';
|
|
|
|
import * as paths from './paths.js';
|
2024-02-15 20:30:38 +01:00
|
|
|
import { PlatformServiceDb } from './classes.platformservicedb.js'
|
2025-05-08 01:13:54 +00:00
|
|
|
import { EmailService } from './mail/services/classes.emailservice.js';
|
2025-03-15 16:24:56 +00:00
|
|
|
import { SmsService } from './sms/classes.smsservice.js';
|
2025-05-08 01:13:54 +00:00
|
|
|
import { MtaService } from './mail/delivery/classes.mta.js';
|
2024-02-15 20:30:38 +01:00
|
|
|
|
|
|
|
export class SzPlatformService {
|
|
|
|
public projectinfo: plugins.projectinfo.ProjectInfo;
|
|
|
|
public serviceQenv = new plugins.qenv.Qenv('./', './.nogit');
|
|
|
|
public platformserviceDb: PlatformServiceDb;
|
|
|
|
|
|
|
|
public typedserver: plugins.typedserver.TypedServer;
|
|
|
|
public typedrouter = new plugins.typedrequest.TypedRouter();
|
|
|
|
|
2024-02-16 20:42:26 +01:00
|
|
|
// SubServices
|
|
|
|
public emailService: EmailService;
|
|
|
|
public mtaService: MtaService;
|
|
|
|
public smsService: SmsService;
|
|
|
|
|
2024-02-15 20:30:38 +01:00
|
|
|
public async start() {
|
|
|
|
this.platformserviceDb = new PlatformServiceDb(this);
|
|
|
|
this.projectinfo = new plugins.projectinfo.ProjectInfo(paths.packageDir);
|
2024-02-16 20:42:26 +01:00
|
|
|
|
|
|
|
// lets start the sub services
|
|
|
|
this.emailService = new EmailService(this);
|
|
|
|
this.mtaService = new MtaService(this);
|
|
|
|
this.smsService = new SmsService(this, {
|
|
|
|
apiGatewayApiToken: await this.serviceQenv.getEnvVarOnDemand('SMS_API_TOKEN'),
|
|
|
|
});
|
|
|
|
|
|
|
|
// lets start the server finally
|
2024-02-15 20:30:38 +01:00
|
|
|
this.typedserver = new plugins.typedserver.TypedServer({
|
|
|
|
cors: true,
|
|
|
|
});
|
|
|
|
await this.typedserver.start();
|
|
|
|
}
|
2025-05-07 22:06:55 +00:00
|
|
|
|
|
|
|
public async stop() {
|
|
|
|
// Stop the server if it's running
|
|
|
|
if (this.typedserver) {
|
|
|
|
await this.typedserver.stop();
|
|
|
|
}
|
|
|
|
}
|
2024-02-15 20:30:38 +01:00
|
|
|
}
|