mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-01 11:13:26 +00:00
refactor contract handling to support single route per contract and improve reference generation logic
This commit is contained in:
@@ -7,4 +7,9 @@ export const minioConfig = registerAs("minio", () => ({
|
||||
accessKey: process.env.MINIO_ACCESS_KEY || "",
|
||||
secretKey: process.env.MINIO_SECRET_KEY || "",
|
||||
bucket: process.env.MINIO_BUCKET || "fhc",
|
||||
// Preset the region so presignedGetObject signs URLs locally. Without it the
|
||||
// minio client fires a live GetBucketLocation request to the endpoint on every
|
||||
// sign — which blocks (no timeout) when MinIO is slow/unreachable and hangs
|
||||
// API responses that reload a booking's files (e.g. staff accept).
|
||||
region: process.env.MINIO_REGION || "us-east-1",
|
||||
}));
|
||||
|
||||
@@ -29,6 +29,9 @@ export class MinioService {
|
||||
useSSL: config.useSSL,
|
||||
accessKey: config.accessKey,
|
||||
secretKey: config.secretKey,
|
||||
// Presetting the region keeps presignedGetObject fully local — no live
|
||||
// GetBucketLocation round-trip to the endpoint on each signed URL.
|
||||
region: config.region,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -108,8 +111,11 @@ export class MinioService {
|
||||
try {
|
||||
return await this.client.presignedGetObject(this.bucket, objectName, expirySeconds);
|
||||
} catch (error) {
|
||||
// Signing a file URL must never break a booking/transition response — the
|
||||
// caller only needs SOMETHING to link to. Degrade to the public object URL
|
||||
// and log, rather than throwing (which would 500 an otherwise-good load).
|
||||
this.logger.error(`Failed to generate signed URL for ${objectName}:`, error);
|
||||
throw error;
|
||||
return this.getPublicUrl(objectName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user