diff --git a/src/config.ts b/src/config.ts index 1dad5cb557..83b3438119 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,3 +1,5 @@ +import { ServerOptions } from './types/ServerOptions'; + export default { secretKey: 'THISISMYSECURETOKEN', host: 'http://localhost', @@ -95,11 +97,11 @@ export default { redisPrefix: 'docker', }, aws_s3: { - region: 'sa-east-1', + region: 'sa-east-1' as any, access_key_id: null, secret_key: null, defaultBucketName: null, endpoint: null, forcePathStyle: null, }, -}; +} as unknown as ServerOptions; diff --git a/src/types/ServerOptions.ts b/src/types/ServerOptions.ts index e0abb78099..50e6ae0cb6 100644 --- a/src/types/ServerOptions.ts +++ b/src/types/ServerOptions.ts @@ -65,5 +65,7 @@ export interface ServerOptions { access_key_id: string | null; secret_key: string | null; defaultBucketName: string | null; + endpoint?: string | null; + forcePathStyle?: boolean | null; }; } diff --git a/src/util/bucketAlreadyExists.ts b/src/util/bucketAlreadyExists.ts index f153c16246..2ba67270c0 100644 --- a/src/util/bucketAlreadyExists.ts +++ b/src/util/bucketAlreadyExists.ts @@ -6,11 +6,11 @@ import config from '../config'; export async function bucketAlreadyExists(bucketName: string) { // eslint-disable-next-line no-async-promise-executor return new Promise(async (resolve, reject) => { - const s3Client = new S3Client({ region: config.aws_s3.region }); - - const command = new HeadBucketCommand({ Bucket: bucketName }); - try { + if (!config.aws_s3.region) throw new Error('Config your AWS environment'); + const s3Client = new S3Client({ region: config.aws_s3.region }); + + const command = new HeadBucketCommand({ Bucket: bucketName }); await s3Client.send(command); resolve(true); } catch (error: any) {