Files
app/ts/reception/classes.receptionserver.ts
T

36 lines
1.2 KiB
TypeScript
Raw Permalink Normal View History

2024-09-29 13:56:38 +02:00
import * as plugins from './plugins.js';
import { Reception } from './classes.reception.js';
export class ReceptionServer {
public receptionRef: Reception;
public serviceServer: plugins.loleServiceServer.ServiceServer;
public typedsocket: plugins.typedsocket.TypedSocket;
constructor(receptionRef: Reception) {
this.receptionRef = receptionRef;
this.serviceServer = new plugins.loleServiceServer.ServiceServer({
serviceDomain: 'reception.lossless.one',
serviceName: 'reception',
serviceVersion: this.receptionRef.projectinfoNpm.version,
port: parseInt(this.receptionRef.serviceQenv.getEnvVarOnDemand('TEST_PORT')) || 3000,
addCustomRoutes: async (serverArg) => {
serverArg.addRoute(
'/typedrequest',
new plugins.loleServiceServer.HandlerTypedRouter(this.receptionRef.typedrouter)
);
},
});
}
async start() {
await this.serviceServer.start();
this.typedsocket = this.serviceServer.typedServer.typedsocket;
this.serviceServer.typedServer.typedrouter.addTypedRouter(this.receptionRef.typedrouter);
}
async stop() {
await this.typedsocket.stop();
await this.serviceServer.stop();
}
}