Skip to content

Commit

Permalink
fix: Fixed variable s3 error
Browse files Browse the repository at this point in the history
  • Loading branch information
icleitoncosta committed Aug 27, 2023
1 parent 4a67d56 commit 5f31606
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/index.ts
Expand Up @@ -57,7 +57,7 @@ export function initServer(serverOptions: any) {
app.use('/files', express.static('WhatsAppImages'));
app.use(boolParser());

if (config.aws_s3.access_key_id && config.aws_s3.secret_key) {
if (config?.aws_s3?.access_key_id && config?.aws_s3?.secret_key) {
process.env['AWS_ACCESS_KEY_ID'] = config.aws_s3.access_key_id;
process.env['AWS_SECRET_ACCESS_KEY'] = config.aws_s3.secret_key;
}
Expand Down
16 changes: 8 additions & 8 deletions src/util/functions.ts
Expand Up @@ -144,18 +144,18 @@ async function autoDownload(client: any, req: any, message: any) {
const hashName = crypto.randomBytes(24).toString('hex');

if (
!config.aws_s3.region ||
!config.aws_s3.access_key_id ||
!config.aws_s3.secret_key
!config?.aws_s3?.region ||
!config?.aws_s3?.access_key_id ||
!config?.aws_s3?.secret_key
)
throw new Error('Please, configure your aws configs');
const s3Client = new S3Client({
region: config.aws_s3.region,
endpoint: config.aws_s3.endpoint || undefined,
forcePathStyle: config.aws_s3.forcePathStyle || undefined,
region: config?.aws_s3?.region,
endpoint: config?.aws_s3?.endpoint || undefined,
forcePathStyle: config?.aws_s3?.forcePathStyle || undefined,
});
let bucketName = config.aws_s3.defaultBucketName
? config.aws_s3.defaultBucketName
let bucketName = config?.aws_s3?.defaultBucketName
? config?.aws_s3?.defaultBucketName
: client.session;
bucketName = bucketName
.normalize('NFD')
Expand Down

0 comments on commit 5f31606

Please sign in to comment.