f40ef6b7c0
Align Cloudly with the current typedserver, smartconfig, smartstate, and Docker tooling releases so builds and Docker output stay compatible with the upgraded stack.
69 lines
2.4 KiB
TypeScript
69 lines
2.4 KiB
TypeScript
import * as plugins from './plugins.js';
|
|
import * as paths from './paths.js';
|
|
import { logger } from './logger.js';
|
|
import type { Cloudly } from './classes.cloudly.js';
|
|
|
|
/**
|
|
* the main cloudly config
|
|
*/
|
|
export class CloudlyConfig {
|
|
public cloudlyRef: Cloudly;
|
|
public appData!: plugins.smartconfig.AppData<plugins.servezoneInterfaces.data.ICloudlyConfig>;
|
|
public data!: plugins.servezoneInterfaces.data.ICloudlyConfig;
|
|
|
|
constructor(cloudlyRefArg: Cloudly) {
|
|
this.cloudlyRef = cloudlyRefArg;
|
|
}
|
|
|
|
public async init(configArg?: plugins.servezoneInterfaces.data.ICloudlyConfig) {
|
|
this.appData =
|
|
await plugins.smartconfig.AppData.createAndInit<plugins.servezoneInterfaces.data.ICloudlyConfig>(
|
|
{
|
|
envMapping: {
|
|
environment: 'SERVEZONE_ENVIRONMENT' as 'production' | 'integration',
|
|
letsEncryptEmail: 'hard:domains@lossless.org',
|
|
letsEncryptPrivateKey: undefined,
|
|
publicUrl: 'SERVEZONE_URL',
|
|
publicPort: 'SERVEZONE_PORT',
|
|
mongoDescriptor: {
|
|
mongoDbUrl: 'MONGODB_URL',
|
|
mongoDbName: 'MONGODB_NAME',
|
|
mongoDbUser: 'MONGODB_USER',
|
|
mongoDbPass: 'MONGODB_PASS',
|
|
},
|
|
s3Descriptor: {
|
|
endpoint: 'S3_ENDPOINT',
|
|
accessKey: 'S3_ACCESSKEY',
|
|
accessSecret: 'S3_SECRETKEY',
|
|
port: 'S3_PORT', // Note: This will remain as a string. Ensure to parse it to an integer where it's used.
|
|
useSsl: 'boolean:S3_USESSL' as any as boolean,
|
|
bucketName: 'S3_BUCKET'
|
|
},
|
|
sslMode:
|
|
'SERVEZONE_SSLMODE' as plugins.servezoneInterfaces.data.ICloudlyConfig['sslMode'],
|
|
servezoneAdminaccount: 'SERVEZONE_ADMINACCOUNT',
|
|
},
|
|
requiredKeys: [
|
|
'letsEncryptEmail',
|
|
'publicUrl',
|
|
'publicPort',
|
|
'sslMode',
|
|
'environment',
|
|
'mongoDescriptor',
|
|
's3Descriptor',
|
|
],
|
|
overwriteObject: configArg,
|
|
},
|
|
);
|
|
|
|
const kvStore = await this.appData.getKvStore();
|
|
|
|
this.data = await kvStore.readAll();
|
|
const missingKeys = await this.appData.logMissingKeys();
|
|
if (missingKeys.length > 0) {
|
|
logger.log('error', `missing keys: ${missingKeys.join(', ')}`);
|
|
throw new Error('missing keys');
|
|
}
|
|
}
|
|
}
|