@kipicore/dbcore 1.1.345 → 1.1.346

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,6 +11,7 @@ const aws_1 = require("../configs/aws");
11
11
  const env_1 = require("../configs/env");
12
12
  const client_s3_1 = require("@aws-sdk/client-s3");
13
13
  const s3_request_presigner_1 = require("@aws-sdk/s3-request-presigner");
14
+ const date_fns_1 = require("date-fns");
14
15
  const uploadFileToS3 = async (localFilePath, s3Key, s3Bucket = env_1.ENV_VARIABLE.AWS_BUCKET_NAME) => {
15
16
  try {
16
17
  const fileContent = fs_1.default.readFileSync(localFilePath);
@@ -35,11 +36,12 @@ const uploadFileToS3 = async (localFilePath, s3Key, s3Bucket = env_1.ENV_VARIABL
35
36
  };
36
37
  exports.uploadFileToS3 = uploadFileToS3;
37
38
  const getPresignedUrl = async (bucket, fileStorage, expiresIn = 60 * 60 * 24) => {
38
- // if (fileStorage.expiredAt && fileStorage.filePath) {
39
- // const currentDate = getTime(subMinutes(new Date(), 5));
40
- // const expireDate = getTime(new Date(fileStorage.expiredAt));
41
- // if (currentDate < expireDate) return fileStorage.filePath as string;
42
- // }
39
+ if (fileStorage.expiredAt && fileStorage.filePath) {
40
+ const currentDate = (0, date_fns_1.getTime)((0, date_fns_1.subMinutes)(new Date(), 5));
41
+ const expireDate = (0, date_fns_1.getTime)(new Date(fileStorage.expiredAt));
42
+ if (currentDate < expireDate)
43
+ return fileStorage.filePath;
44
+ }
43
45
  const s3Key = `${fileStorage.storagePath}/${fileStorage.storageFileName}`;
44
46
  const command = new client_s3_1.GetObjectCommand({
45
47
  Bucket: bucket,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kipicore/dbcore",
3
- "version": "1.1.345",
3
+ "version": "1.1.346",
4
4
  "description": "Reusable DB core package with Postgres, MongoDB, models, services, interfaces, and types",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",