2024-10-01 13:49:18 +02:00
|
|
|
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';
|
2025-12-01 09:18:48 +00:00
|
|
|
import { AppManager } from './classes.appmanager.js';
|
|
|
|
|
import { AppConnectionManager } from './classes.appconnectionmanager.js';
|
2025-12-01 18:56:16 +00:00
|
|
|
import { ActivityLogManager } from './classes.activitylogmanager.js';
|
2025-12-04 17:45:40 +00:00
|
|
|
import { UserInvitationManager } from './classes.userinvitationmanager.js';
|
2025-12-15 19:45:57 +00:00
|
|
|
import { OidcManager } from './classes.oidcmanager.js';
|
2026-04-20 09:46:13 +00:00
|
|
|
import { AbuseProtectionManager } from './classes.abuseprotectionmanager.js';
|
2026-04-20 10:26:22 +00:00
|
|
|
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
|
|
|
|
2024-10-01 13:49:18 +02:00
|
|
|
export interface IReceptionOptions {
|
|
|
|
|
/**
|
|
|
|
|
* a name for the idp instance.
|
|
|
|
|
*/
|
|
|
|
|
name: string;
|
|
|
|
|
mongoDescriptor: plugins.smartdata.IMongoDescriptor;
|
|
|
|
|
websiteServer: plugins.typedserver.utilityservers.UtilityWebsiteServer;
|
2024-10-04 15:43:36 +02:00
|
|
|
baseUrl: string;
|
2024-10-01 13:49:18 +02:00
|
|
|
}
|
|
|
|
|
|
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);
|
2025-12-01 09:18:48 +00:00
|
|
|
public appManager = new AppManager(this);
|
|
|
|
|
public appConnectionManager = new AppConnectionManager(this);
|
2025-12-01 18:56:16 +00:00
|
|
|
public activityLogManager = new ActivityLogManager(this);
|
2026-04-20 10:26:22 +00:00
|
|
|
public alertManager = new AlertManager(this);
|
2025-12-04 17:45:40 +00:00
|
|
|
public userInvitationManager = new UserInvitationManager(this);
|
2026-04-20 09:46:13 +00:00
|
|
|
public abuseProtectionManager = new AbuseProtectionManager(this);
|
2026-04-20 10:26:22 +00:00
|
|
|
public passportPushManager = new PassportPushManager(this);
|
|
|
|
|
public passportManager = new PassportManager(this);
|
2025-12-15 19:45:57 +00:00
|
|
|
public oidcManager = new OidcManager(this);
|
2024-09-29 13:56:38 +02:00
|
|
|
housekeeping = new ReceptionHousekeeping(this);
|
|
|
|
|
|
2024-10-01 13:49:18 +02:00
|
|
|
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() {
|
2026-05-07 15:35:37 +00:00
|
|
|
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');
|
2024-10-01 13:49:18 +02:00
|
|
|
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();
|
2026-05-07 15:35:37 +00:00
|
|
|
await this.housekeeping.start();
|
2024-09-29 13:56:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* stops the reception instance
|
|
|
|
|
*/
|
|
|
|
|
public async stop() {
|
|
|
|
|
await this.housekeeping.stop();
|
2026-04-20 08:40:40 +00:00
|
|
|
await this.oidcManager.stop();
|
2024-09-29 13:56:38 +02:00
|
|
|
console.log('stopped serviceserver!');
|
|
|
|
|
await this.db.stop();
|
|
|
|
|
}
|
|
|
|
|
}
|