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

96 lines
4.0 KiB
TypeScript
Raw Normal View History

import * as plugins from '../plugins.js';
2024-09-29 13:56:38 +02:00
import { logger } from './logging.js';
import { JwtManager } from './classes.jwtmanager.js';
import { LoginSessionManager } from './classes.loginsessionmanager.js';
import { RegistrationSessionManager } from './classes.registrationsessionmanager.js';
import { ReceptionDb } from './classes.receptiondb.js';
import { ReceptionMailer } from './classes.receptionmailer.js';
import { UserManager } from './classes.usermanager.js';
import { ApiTokenManager } from './classes.apitokenmanager.js';
import { ReceptionHousekeeping } from './classes.housekeeping.js';
import { OrganizationManager } from './classes.organizationmanager.js';
import { RoleManager } from './classes.rolemanager.js';
import { BillingPlanManager } from './classes.billingplanmanager.js';
import { AppManager } from './classes.appmanager.js';
import { AppConnectionManager } from './classes.appconnectionmanager.js';
import { ActivityLogManager } from './classes.activitylogmanager.js';
2025-12-04 17:45:40 +00:00
import { UserInvitationManager } from './classes.userinvitationmanager.js';
import { OidcManager } from './classes.oidcmanager.js';
import { AbuseProtectionManager } from './classes.abuseprotectionmanager.js';
import { AlertManager } from './classes.alertmanager.js';
import { PassportManager } from './classes.passportmanager.js';
import { PassportPushManager } from './classes.passportpushmanager.js';
2024-09-29 13:56:38 +02:00
export interface IReceptionOptions {
/**
* a name for the idp instance.
*/
name: string;
mongoDescriptor: plugins.smartdata.IMongoDescriptor;
websiteServer: plugins.typedserver.utilityservers.UtilityWebsiteServer;
baseUrl: string;
}
2024-09-29 13:56:38 +02:00
export class Reception {
public typedrouter = new plugins.typedrequest.TypedRouter();
public serviceQenv = new plugins.qenv.Qenv('./', './.nogit');
public szPlatformClient = new plugins.szPlatformClient.SzPlatformClient();
public db = new ReceptionDb(this);
// managers
public jwtManager = new JwtManager(this);
public loginSessionManager = new LoginSessionManager(this);
public registrationSessionManager = new RegistrationSessionManager(this);
public apitokenManager = new ApiTokenManager(this);
public receptionMailer = new ReceptionMailer(this);
public userManager = new UserManager(this);
public organizationmanager = new OrganizationManager(this);
public roleManager = new RoleManager(this);
public billingPlanManager = new BillingPlanManager(this);
public appManager = new AppManager(this);
public appConnectionManager = new AppConnectionManager(this);
public activityLogManager = new ActivityLogManager(this);
public alertManager = new AlertManager(this);
2025-12-04 17:45:40 +00:00
public userInvitationManager = new UserInvitationManager(this);
public abuseProtectionManager = new AbuseProtectionManager(this);
public passportPushManager = new PassportPushManager(this);
public passportManager = new PassportManager(this);
public oidcManager = new OidcManager(this);
2024-09-29 13:56:38 +02:00
housekeeping = new ReceptionHousekeeping(this);
constructor(public options: IReceptionOptions) {
if (!options.mongoDescriptor) {
throw new Error('mongoDescriptor is required');
}
if (!options.websiteServer) {
throw new Error('websiteServer is required');
}
}
2024-09-29 13:56:38 +02:00
/**
* starts the reception instance
*/
public async start() {
const serveZoneAuthorization = await this.serviceQenv.getEnvVarOnDemand('SERVEZONE_PLATFORM_AUTHORIZATION');
await this.szPlatformClient.init(serveZoneAuthorization || 'test');
2024-09-29 13:56:38 +02:00
logger.log('info', 'starting reception');
logger.log('info', 'adding typedrouter to website server');
this.options.websiteServer.typedrouter.addTypedRouter(this.typedrouter);
logger.log('info', 'starting database');
await this.db.start();
2024-09-29 13:56:38 +02:00
await this.jwtManager.start();
await this.housekeeping.start();
2024-09-29 13:56:38 +02:00
}
/**
* stops the reception instance
*/
public async stop() {
await this.housekeeping.stop();
await this.oidcManager.stop();
2024-09-29 13:56:38 +02:00
console.log('stopped serviceserver!');
await this.db.stop();
}
}