@kipicore/dbcore 1.1.346 → 1.1.348
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,7 +11,6 @@ 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");
|
|
15
14
|
const uploadFileToS3 = async (localFilePath, s3Key, s3Bucket = env_1.ENV_VARIABLE.AWS_BUCKET_NAME) => {
|
|
16
15
|
try {
|
|
17
16
|
const fileContent = fs_1.default.readFileSync(localFilePath);
|
|
@@ -36,29 +35,14 @@ const uploadFileToS3 = async (localFilePath, s3Key, s3Bucket = env_1.ENV_VARIABL
|
|
|
36
35
|
};
|
|
37
36
|
exports.uploadFileToS3 = uploadFileToS3;
|
|
38
37
|
const getPresignedUrl = async (bucket, fileStorage, expiresIn = 60 * 60 * 24) => {
|
|
39
|
-
if (fileStorage.
|
|
40
|
-
|
|
41
|
-
const expireDate = (0, date_fns_1.getTime)(new Date(fileStorage.expiredAt));
|
|
42
|
-
if (currentDate < expireDate)
|
|
43
|
-
return fileStorage.filePath;
|
|
44
|
-
}
|
|
38
|
+
if (fileStorage.filePath)
|
|
39
|
+
return fileStorage.filePath;
|
|
45
40
|
const s3Key = `${fileStorage.storagePath}/${fileStorage.storageFileName}`;
|
|
46
41
|
const command = new client_s3_1.GetObjectCommand({
|
|
47
42
|
Bucket: bucket,
|
|
48
43
|
Key: s3Key,
|
|
49
44
|
});
|
|
50
45
|
const signedUrl = await (0, s3_request_presigner_1.getSignedUrl)(aws_1.s3, command, { expiresIn }); // in seconds
|
|
51
|
-
// if (fileStorage.id) {
|
|
52
|
-
// await FileStorageModel.update(
|
|
53
|
-
// {
|
|
54
|
-
// filePath: signedUrl,
|
|
55
|
-
// expiredAt: addDays(new Date(), 1),
|
|
56
|
-
// },I
|
|
57
|
-
// {
|
|
58
|
-
// where: { id: fileStorage.id },
|
|
59
|
-
// },
|
|
60
|
-
// );
|
|
61
|
-
// }
|
|
62
46
|
return signedUrl;
|
|
63
47
|
};
|
|
64
48
|
exports.getPresignedUrl = getPresignedUrl;
|
|
@@ -3,8 +3,11 @@ import { Document } from 'mongoose';
|
|
|
3
3
|
export interface ICertificatesHistoryAttributes extends IDefaultAttributes, Document {
|
|
4
4
|
id: string;
|
|
5
5
|
instituteId?: string;
|
|
6
|
-
userInstituteMetaId: string
|
|
6
|
+
userInstituteMetaId: string;
|
|
7
7
|
certificatesManagementId: string;
|
|
8
8
|
additionalData: object;
|
|
9
9
|
academicCalendarId?: string;
|
|
10
|
+
userId: string;
|
|
11
|
+
groupId: string;
|
|
12
|
+
certificateNumber: number;
|
|
10
13
|
}
|
|
@@ -43,12 +43,10 @@ const CertificatesHistorySchema = new mongoose_1.Schema({
|
|
|
43
43
|
type: String,
|
|
44
44
|
required: false,
|
|
45
45
|
},
|
|
46
|
-
userInstituteMetaId:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
},
|
|
51
|
-
],
|
|
46
|
+
userInstituteMetaId: {
|
|
47
|
+
type: String,
|
|
48
|
+
required: true,
|
|
49
|
+
},
|
|
52
50
|
additionalData: {
|
|
53
51
|
type: Object,
|
|
54
52
|
required: false,
|
|
@@ -56,7 +54,19 @@ const CertificatesHistorySchema = new mongoose_1.Schema({
|
|
|
56
54
|
academicCalendarId: {
|
|
57
55
|
type: String,
|
|
58
56
|
required: false,
|
|
59
|
-
}
|
|
57
|
+
},
|
|
58
|
+
userId: {
|
|
59
|
+
type: String,
|
|
60
|
+
required: false,
|
|
61
|
+
},
|
|
62
|
+
groupId: {
|
|
63
|
+
type: String,
|
|
64
|
+
required: false,
|
|
65
|
+
},
|
|
66
|
+
certificateNumber: {
|
|
67
|
+
type: Number,
|
|
68
|
+
required: false,
|
|
69
|
+
},
|
|
60
70
|
}, { timestamps: true, versionKey: false });
|
|
61
71
|
const CertificatesHistory = mongoose_1.default.model('certificates_history', CertificatesHistorySchema);
|
|
62
72
|
exports.default = CertificatesHistory;
|
package/package.json
CHANGED