platformservice/ts/classes.platformservice.ts
2024-02-16 20:42:26 +01:00

44 lines
1.7 KiB
TypeScript

import * as plugins from './plugins.js';
import * as paths from './paths.js';
import { PlatformServiceDb } from './classes.platformservicedb.js'
import { EmailService } from './email/email.classes.emailservice.js';
import { SmsService } from './sms/smsservice.js';
import { LetterService } from './letter/classes.letterservice.js';
import { MtaService } from './mta/mta.classes.mta.js';
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();
// SubServices
public emailService: EmailService;
public letterService: LetterService;
public mtaService: MtaService;
public smsService: SmsService;
public async start() {
this.platformserviceDb = new PlatformServiceDb(this);
this.projectinfo = new plugins.projectinfo.ProjectInfo(paths.packageDir);
// lets start the sub services
this.emailService = new EmailService(this);
this.letterService = new LetterService(this, {
letterxpressUser: await this.serviceQenv.getEnvVarOnDemand('LETTER_API_USER'),
letterxpressToken: await this.serviceQenv.getEnvVarOnDemand('LETTER_API_TOKEN')
});
this.mtaService = new MtaService(this);
this.smsService = new SmsService(this, {
apiGatewayApiToken: await this.serviceQenv.getEnvVarOnDemand('SMS_API_TOKEN'),
});
// lets start the server finally
this.typedserver = new plugins.typedserver.TypedServer({
cors: true,
});
await this.typedserver.start();
}
}