fix(services): Update S3 credentials naming and add S3_ENDPOINT support for improved MinIO integration
This commit is contained in:
@@ -13,9 +13,10 @@ export interface IServiceConfig {
|
||||
S3_HOST: string;
|
||||
S3_PORT: string;
|
||||
S3_CONSOLE_PORT: string;
|
||||
S3_USER: string;
|
||||
S3_PASS: string;
|
||||
S3_ACCESSKEY: string;
|
||||
S3_SECRETKEY: string;
|
||||
S3_BUCKET: string;
|
||||
S3_ENDPOINT: string;
|
||||
}
|
||||
|
||||
export class ServiceConfiguration {
|
||||
@@ -101,6 +102,8 @@ export class ServiceConfiguration {
|
||||
const mongoHost = 'localhost';
|
||||
const mongoName = projectName;
|
||||
const mongoPortStr = mongoPort.toString();
|
||||
const s3Host = 'localhost';
|
||||
const s3PortStr = s3Port.toString();
|
||||
|
||||
this.config = {
|
||||
PROJECT_NAME: projectName,
|
||||
@@ -110,12 +113,13 @@ export class ServiceConfiguration {
|
||||
MONGODB_USER: mongoUser,
|
||||
MONGODB_PASS: mongoPass,
|
||||
MONGODB_URL: `mongodb://${mongoUser}:${mongoPass}@${mongoHost}:${mongoPortStr}/${mongoName}?authSource=admin`,
|
||||
S3_HOST: 'localhost',
|
||||
S3_PORT: s3Port.toString(),
|
||||
S3_HOST: s3Host,
|
||||
S3_PORT: s3PortStr,
|
||||
S3_CONSOLE_PORT: s3ConsolePort.toString(),
|
||||
S3_USER: 'defaultadmin',
|
||||
S3_PASS: 'defaultpass',
|
||||
S3_BUCKET: `${projectName}-documents`
|
||||
S3_ACCESSKEY: 'defaultadmin',
|
||||
S3_SECRETKEY: 'defaultpass',
|
||||
S3_BUCKET: `${projectName}-documents`,
|
||||
S3_ENDPOINT: `http://${s3Host}:${s3PortStr}`
|
||||
};
|
||||
|
||||
await this.saveConfig();
|
||||
@@ -206,15 +210,15 @@ export class ServiceConfiguration {
|
||||
updated = true;
|
||||
}
|
||||
|
||||
if (!this.config.S3_USER) {
|
||||
this.config.S3_USER = 'defaultadmin';
|
||||
fieldsAdded.push('S3_USER');
|
||||
if (!this.config.S3_ACCESSKEY) {
|
||||
this.config.S3_ACCESSKEY = 'defaultadmin';
|
||||
fieldsAdded.push('S3_ACCESSKEY');
|
||||
updated = true;
|
||||
}
|
||||
|
||||
if (!this.config.S3_PASS) {
|
||||
this.config.S3_PASS = 'defaultpass';
|
||||
fieldsAdded.push('S3_PASS');
|
||||
if (!this.config.S3_SECRETKEY) {
|
||||
this.config.S3_SECRETKEY = 'defaultpass';
|
||||
fieldsAdded.push('S3_SECRETKEY');
|
||||
updated = true;
|
||||
}
|
||||
|
||||
@@ -224,6 +228,14 @@ export class ServiceConfiguration {
|
||||
updated = true;
|
||||
}
|
||||
|
||||
// Always update S3_ENDPOINT based on current settings
|
||||
const oldEndpoint = this.config.S3_ENDPOINT;
|
||||
this.config.S3_ENDPOINT = `http://${this.config.S3_HOST}:${this.config.S3_PORT}`;
|
||||
if (oldEndpoint !== this.config.S3_ENDPOINT) {
|
||||
fieldsAdded.push('S3_ENDPOINT');
|
||||
updated = true;
|
||||
}
|
||||
|
||||
if (updated) {
|
||||
await this.saveConfig();
|
||||
logger.log('ok', `✅ Added missing fields: ${fieldsAdded.join(', ')}`);
|
||||
|
Reference in New Issue
Block a user