refactor(core): Port endpoints config (no-changelog) (#10268)

This commit is contained in:
Iván Ovejero
2024-07-31 17:45:11 +02:00
committed by GitHub
parent d91eb2cdd5
commit 1608d2527b
21 changed files with 275 additions and 228 deletions

View File

@@ -34,7 +34,7 @@ export abstract class AbstractServer {
protected externalHooks: ExternalHooks;
protected protocol = Container.get(GlobalConfig).protocol;
protected globalConfig = Container.get(GlobalConfig);
protected sslKey: string;
@@ -74,15 +74,15 @@ export abstract class AbstractServer {
this.sslKey = config.getEnv('ssl_key');
this.sslCert = config.getEnv('ssl_cert');
this.restEndpoint = config.getEnv('endpoints.rest');
this.restEndpoint = this.globalConfig.endpoints.rest;
this.endpointForm = config.getEnv('endpoints.form');
this.endpointFormTest = config.getEnv('endpoints.formTest');
this.endpointFormWaiting = config.getEnv('endpoints.formWaiting');
this.endpointForm = this.globalConfig.endpoints.form;
this.endpointFormTest = this.globalConfig.endpoints.formTest;
this.endpointFormWaiting = this.globalConfig.endpoints.formWaiting;
this.endpointWebhook = config.getEnv('endpoints.webhook');
this.endpointWebhookTest = config.getEnv('endpoints.webhookTest');
this.endpointWebhookWaiting = config.getEnv('endpoints.webhookWaiting');
this.endpointWebhook = this.globalConfig.endpoints.webhook;
this.endpointWebhookTest = this.globalConfig.endpoints.webhookTest;
this.endpointWebhookWaiting = this.globalConfig.endpoints.webhookWaiting;
this.uniqueInstanceId = generateHostInstanceId(instanceType);
@@ -134,7 +134,8 @@ export abstract class AbstractServer {
}
async init(): Promise<void> {
const { app, protocol, sslKey, sslCert } = this;
const { app, sslKey, sslCert } = this;
const { protocol } = this.globalConfig;
if (protocol === 'https' && sslKey && sslCert) {
const https = await import('https');
@@ -261,14 +262,16 @@ export abstract class AbstractServer {
return;
}
this.logger.debug(`Shutting down ${this.protocol} server`);
const { protocol } = this.globalConfig;
this.logger.debug(`Shutting down ${protocol} server`);
this.server.close((error) => {
if (error) {
this.logger.error(`Error while shutting down ${this.protocol} server`, { error });
this.logger.error(`Error while shutting down ${protocol} server`, { error });
}
this.logger.debug(`${this.protocol} server shut down`);
this.logger.debug(`${protocol} server shut down`);
});
}
}