@triproject/nestjs-core 1.0.28 → 1.0.30
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.
- package/dist/bootstrap.js +39 -1
- package/dist/config.js +257 -1
- package/dist/controllers/controller.js +53 -1
- package/dist/drivers/cache/cache.js +79 -1
- package/dist/drivers/cache/cache.module.js +30 -1
- package/dist/drivers/cache/index.js +14 -1
- package/dist/drivers/cache/redis.js +76 -1
- package/dist/drivers/db/db.helper.d.ts +1 -1
- package/dist/drivers/db/db.helper.js +276 -1
- package/dist/drivers/db/db.module.js +64 -1
- package/dist/drivers/db/db.service.js +52 -1
- package/dist/drivers/db/index.js +14 -1
- package/dist/drivers/db/migration.js +119 -1
- package/dist/drivers/db/repository.js +258 -1
- package/dist/drivers/encryptions/encryption.js +55 -1
- package/dist/drivers/encryptions/encryption.module.js +34 -1
- package/dist/drivers/encryptions/index.js +14 -1
- package/dist/drivers/encryptions/jwt.js +62 -1
- package/dist/drivers/encryptions/password-hash.js +48 -1
- package/dist/drivers/encryptions/snap.signature.js +111 -1
- package/dist/drivers/logger/app.logger.js +121 -2
- package/dist/drivers/logger/cloudwatch.js +73 -1
- package/dist/drivers/logger/index.js +12 -1
- package/dist/drivers/logger/logger.contract.js +29 -1
- package/dist/drivers/logger/logger.driver.js +49 -1
- package/dist/drivers/logger/slack.logger.js +42 -1
- package/dist/drivers/mail/index.js +14 -1
- package/dist/drivers/mail/mail-template.js +39 -6
- package/dist/drivers/mail/mail.config.js +10 -1
- package/dist/drivers/mail/mail.js +58 -13
- package/dist/drivers/mail/mail.module.js +36 -1
- package/dist/drivers/mail/mail.queue.js +45 -1
- package/dist/drivers/mail/mailer.js +64 -1
- package/dist/drivers/message-broker/index.js +14 -1
- package/dist/drivers/message-broker/kafka.js +104 -1
- package/dist/drivers/message-broker/message-broker.contract.js +24 -1
- package/dist/drivers/message-broker/message-broker.module.js +28 -1
- package/dist/drivers/message-broker/message.broker.js +67 -1
- package/dist/drivers/message-broker/rabbitmq.js +115 -1
- package/dist/drivers/notifications/index.js +14 -1
- package/dist/drivers/notifications/notification.config.js +10 -1
- package/dist/drivers/notifications/notification.module.js +34 -1
- package/dist/drivers/notifications/notification.queue.js +45 -1
- package/dist/drivers/notifications/push-notification.js +81 -1
- package/dist/drivers/notifications/slack.js +74 -1
- package/dist/drivers/queues/app.queue.js +77 -1
- package/dist/drivers/queues/index.js +14 -1
- package/dist/drivers/queues/queue.module.js +51 -1
- package/dist/drivers/secret-manager/aws-secret-manager.js +40 -1
- package/dist/drivers/secret-manager/index.js +50 -1
- package/dist/drivers/storage/csv.storage.js +71 -1
- package/dist/drivers/storage/excel.storage.js +57 -1
- package/dist/drivers/storage/index.js +14 -1
- package/dist/drivers/storage/local.storage.js +94 -1
- package/dist/drivers/storage/minio.storage.js +82 -1
- package/dist/drivers/storage/s3-storage.js +122 -1
- package/dist/drivers/storage/storage.contract.js +31 -1
- package/dist/drivers/storage/storage.module.js +32 -1
- package/dist/drivers/storage/storage.service.js +59 -1
- package/dist/helpers/exception.helper.js +132 -1
- package/dist/helpers/http.helper.js +163 -1
- package/dist/helpers/swagger.helper.js +474 -1
- package/dist/index.js +14 -1
- package/dist/types.d.js +4 -1
- package/dist/utils/redlock.js +51 -1
- package/dist/utils/throttle.js +68 -1
- package/dist/utils/totp.js +56 -1
- package/package.json +13 -11
|
@@ -1 +1,94 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var obj;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: !0
|
|
5
|
+
}), Object.defineProperty(exports, "LocalStorageService", {
|
|
6
|
+
enumerable: !0,
|
|
7
|
+
get: function() {
|
|
8
|
+
return LocalStorageService;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
let _helpers = require("@triproject/helpers"), _fs = require("fs"), _path = (obj = require("path")) && obj.__esModule ? obj : {
|
|
12
|
+
default: obj
|
|
13
|
+
}, _exceptionhelper = require("../../helpers/exception.helper"), _secretmanager = require("../secret-manager");
|
|
14
|
+
let LocalStorageService = class LocalStorageService {
|
|
15
|
+
expiresIn = 3600;
|
|
16
|
+
BUCKET;
|
|
17
|
+
constructor(){
|
|
18
|
+
(0, _secretmanager.getSecret)().then((conf)=>{
|
|
19
|
+
this.BUCKET = conf.S3_BUCKET;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
_getPath(relativePath) {
|
|
23
|
+
return _path.default.join(this.BUCKET, relativePath);
|
|
24
|
+
}
|
|
25
|
+
async get(path) {
|
|
26
|
+
return {
|
|
27
|
+
url: this._getPath(path),
|
|
28
|
+
fileName: (0, _helpers.getFileName)(path)
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
async upload(filePath, file) {
|
|
32
|
+
let fullFilePath = this._getPath(filePath);
|
|
33
|
+
return (0, _fs.mkdirSync)(_path.default.dirname(fullFilePath), {
|
|
34
|
+
recursive: !0
|
|
35
|
+
}), (0, _fs.writeFileSync)(fullFilePath, file), this.get(filePath);
|
|
36
|
+
}
|
|
37
|
+
async move(oldPath, newPath) {
|
|
38
|
+
let oldFullPath = this._getPath(oldPath), newFullPath = this._getPath(newPath);
|
|
39
|
+
try {
|
|
40
|
+
if (await this.isExists(oldFullPath)) return (0, _fs.mkdirSync)(_path.default.dirname(newFullPath), {
|
|
41
|
+
recursive: !0
|
|
42
|
+
}), (0, _fs.renameSync)(oldFullPath, newFullPath), !0;
|
|
43
|
+
return !1;
|
|
44
|
+
} catch (error) {
|
|
45
|
+
throw new _exceptionhelper.AppUnprocessableEntityException(`Failed to rename file from ${oldPath} to ${newPath}: ${error?.message}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
delete(path) {
|
|
49
|
+
let fullFilePath = this._getPath(path);
|
|
50
|
+
this._assertFileExists(fullFilePath);
|
|
51
|
+
try {
|
|
52
|
+
return (0, _fs.unlinkSync)(fullFilePath), Promise.resolve();
|
|
53
|
+
} catch (error) {
|
|
54
|
+
throw new _exceptionhelper.AppUnprocessableEntityException(`Failed to delete file ${path}: ${error?.message}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async getBase64(filePath) {
|
|
58
|
+
let fullFilePath = this._getPath(filePath);
|
|
59
|
+
this._assertFileExists(fullFilePath);
|
|
60
|
+
try {
|
|
61
|
+
let base64 = (0, _fs.readFileSync)(fullFilePath).toString('base64'), mimeType = this._getMimeType(filePath);
|
|
62
|
+
return `data:${mimeType};base64,${base64}`;
|
|
63
|
+
} catch (error) {
|
|
64
|
+
throw new _exceptionhelper.AppUnprocessableEntityException(`Failed to get base64 for ${filePath}: ${error?.message}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
_getMimeType(filePath) {
|
|
68
|
+
let fullFilePath = this._getPath(filePath);
|
|
69
|
+
this._assertFileExists(fullFilePath);
|
|
70
|
+
try {
|
|
71
|
+
switch(_path.default.extname(filePath).toLowerCase()){
|
|
72
|
+
case '.png':
|
|
73
|
+
return 'image/png';
|
|
74
|
+
case '.jpg':
|
|
75
|
+
case '.jpeg':
|
|
76
|
+
return 'image/jpeg';
|
|
77
|
+
default:
|
|
78
|
+
return 'application/octet-stream';
|
|
79
|
+
}
|
|
80
|
+
} catch (error) {
|
|
81
|
+
throw new _exceptionhelper.AppUnprocessableEntityException(`Failed to get MIME type for ${filePath}: ${error?.message}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
async isExists(filePath) {
|
|
85
|
+
try {
|
|
86
|
+
return (0, _fs.accessSync)(this._getPath(filePath)), !0;
|
|
87
|
+
} catch {
|
|
88
|
+
return !1;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
_assertFileExists(filePath) {
|
|
92
|
+
if (!this.isExists(filePath)) throw new _exceptionhelper.AppUnprocessableEntityException(`File not found: ${filePath}`);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
@@ -1 +1,82 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: !0
|
|
4
|
+
}), Object.defineProperty(exports, "MinioStorage", {
|
|
5
|
+
enumerable: !0,
|
|
6
|
+
get: function() {
|
|
7
|
+
return MinioStorage;
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
let _helpers = require("@triproject/helpers"), _minio = require("minio"), _exceptionhelper = require("../../helpers/exception.helper"), _secretmanager = require("../secret-manager");
|
|
11
|
+
let MinioStorage = class MinioStorage {
|
|
12
|
+
expiresIn;
|
|
13
|
+
client;
|
|
14
|
+
BUCKET;
|
|
15
|
+
constructor(){
|
|
16
|
+
(0, _secretmanager.getSecret)().then((secret)=>{
|
|
17
|
+
if (!secret.MINIO_HOST) throw new _exceptionhelper.AppUnprocessableEntityException('MINIO_HOST is not defined in secret manager.');
|
|
18
|
+
this.BUCKET = this.BUCKET, this.client = new _minio.Client({
|
|
19
|
+
endPoint: secret.MINIO_HOST,
|
|
20
|
+
port: +secret.MINIO_PORT,
|
|
21
|
+
useSSL: secret.MINIO_USE_SSL,
|
|
22
|
+
accessKey: secret.S3_ACCESS_KEY_ID,
|
|
23
|
+
secretKey: secret.S3_SECRET_ACCESS_KEY
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
async get(fileName, expiresIn = 86400) {
|
|
28
|
+
if (!fileName) throw new _exceptionhelper.AppUnprocessableEntityException('File name is required to get URL.');
|
|
29
|
+
let ext = (0, _helpers.getFileExtension)(fileName), isImage = [
|
|
30
|
+
'png',
|
|
31
|
+
'jpg',
|
|
32
|
+
'jpeg',
|
|
33
|
+
'gif',
|
|
34
|
+
'webp',
|
|
35
|
+
'svg',
|
|
36
|
+
'ico',
|
|
37
|
+
'jpeg',
|
|
38
|
+
'bmp'
|
|
39
|
+
].includes(ext);
|
|
40
|
+
return {
|
|
41
|
+
url: await this.client.presignedUrl('GET', this.BUCKET, fileName, expiresIn, (0, _helpers.removeEmptyValues)({
|
|
42
|
+
'Content-Type': isImage ? 'image' : void 0,
|
|
43
|
+
'Content-Disposition': isImage ? `inline; filename="${fileName}"` : void 0,
|
|
44
|
+
'response-content-type': isImage ? 'image/' + ext : void 0
|
|
45
|
+
})).catch(()=>''),
|
|
46
|
+
fileName: (0, _helpers.getFileName)(fileName)
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
async upload(fileName, file, expiresIn) {
|
|
50
|
+
return await this.client.putObject(this.BUCKET, fileName, file), expiresIn && await this.client.presignedPutObject(this.BUCKET, fileName, expiresIn), await this.get(fileName, expiresIn);
|
|
51
|
+
}
|
|
52
|
+
async delete(path) {
|
|
53
|
+
return await this.client.removeObject(this.BUCKET, path);
|
|
54
|
+
}
|
|
55
|
+
async isExists(fileName) {
|
|
56
|
+
return await this.client.getObject(this.BUCKET, fileName).then(()=>!0).catch(()=>!1);
|
|
57
|
+
}
|
|
58
|
+
async move(oldPath, newPath) {
|
|
59
|
+
let copyConditions = new _minio.CopyConditions();
|
|
60
|
+
try {
|
|
61
|
+
return await this.client.copyObject(this.BUCKET, newPath, `${this.BUCKET}/${oldPath}`, copyConditions), await this.client.removeObject(this.BUCKET, oldPath), !0;
|
|
62
|
+
} catch (error) {
|
|
63
|
+
return !1;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
async getBase64(fileName) {
|
|
67
|
+
return this.stream(fileName, (buffer)=>`${buffer.toString('base64')}`);
|
|
68
|
+
}
|
|
69
|
+
async stream(fileName, processFn) {
|
|
70
|
+
try {
|
|
71
|
+
let stream = await this.client.getObject(this.BUCKET, fileName), chunks = [], mimeType = 'application/octet-stream';
|
|
72
|
+
return new Promise((resolve, reject)=>{
|
|
73
|
+
stream.on('data', (chunk)=>chunks.push(chunk)), stream.on('end', ()=>{
|
|
74
|
+
let buffer = Buffer.concat(chunks);
|
|
75
|
+
mimeType = stream.headers?.['content-type'] || mimeType, resolve(processFn(buffer, mimeType));
|
|
76
|
+
}), stream.on('error', (err)=>reject(err));
|
|
77
|
+
});
|
|
78
|
+
} catch (error) {
|
|
79
|
+
throw Error(`Failed to process file ${fileName}: ${error.message}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
};
|
|
@@ -1 +1,122 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: !0
|
|
4
|
+
}), Object.defineProperty(exports, "S3Storage", {
|
|
5
|
+
enumerable: !0,
|
|
6
|
+
get: function() {
|
|
7
|
+
return S3Storage;
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
let _clients3 = require("@aws-sdk/client-s3"), _s3requestpresigner = require("@aws-sdk/s3-request-presigner"), _helpers = require("@triproject/helpers"), _exceptionhelper = require("../../helpers/exception.helper"), _secretmanager = require("../secret-manager");
|
|
11
|
+
let S3Storage = class S3Storage {
|
|
12
|
+
client;
|
|
13
|
+
BUCKET;
|
|
14
|
+
expiresIn = 3600;
|
|
15
|
+
constructor(){
|
|
16
|
+
(0, _secretmanager.getSecret)().then((secret)=>{
|
|
17
|
+
's3' === secret.STORAGE_DRIVER && (this.BUCKET = secret.S3_BUCKET, this.client = new _clients3.S3Client({
|
|
18
|
+
region: secret.S3_REGION,
|
|
19
|
+
credentials: {
|
|
20
|
+
accessKeyId: secret.S3_ACCESS_KEY_ID,
|
|
21
|
+
secretAccessKey: secret.S3_SECRET_ACCESS_KEY
|
|
22
|
+
}
|
|
23
|
+
}));
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
async get(path, ttl = this.expiresIn) {
|
|
27
|
+
if (!this.client) throw new _exceptionhelper.AppUnprocessableEntityException('S3 Client is not initialized yet');
|
|
28
|
+
let ext = (0, _helpers.getFileExtension)(path), isImage = [
|
|
29
|
+
'png',
|
|
30
|
+
'jpg',
|
|
31
|
+
'jpeg',
|
|
32
|
+
'gif',
|
|
33
|
+
'webp',
|
|
34
|
+
'svg',
|
|
35
|
+
'ico',
|
|
36
|
+
'jpeg'
|
|
37
|
+
].includes(ext), command = new _clients3.GetObjectCommand((0, _helpers.removeEmptyValues)({
|
|
38
|
+
Bucket: this.BUCKET,
|
|
39
|
+
Key: path,
|
|
40
|
+
ResponseContentType: isImage ? 'image/' + ext : void 0
|
|
41
|
+
}));
|
|
42
|
+
return {
|
|
43
|
+
url: await (0, _s3requestpresigner.getSignedUrl)(this.client, command, {
|
|
44
|
+
expiresIn: ttl ?? this.expiresIn
|
|
45
|
+
}),
|
|
46
|
+
fileName: (0, _helpers.getFileName)(path)
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
async upload(path, file, expiresIn) {
|
|
50
|
+
if (!this.client) throw new _exceptionhelper.AppUnprocessableEntityException('S3 Client is not initialized yet');
|
|
51
|
+
return new _clients3.PutObjectCommand({
|
|
52
|
+
Bucket: this.BUCKET,
|
|
53
|
+
Key: path,
|
|
54
|
+
Body: file,
|
|
55
|
+
Expires: expiresIn ? new Date(Date.now() + 1000 * expiresIn) : void 0
|
|
56
|
+
}), await this.get(path);
|
|
57
|
+
}
|
|
58
|
+
async delete(path) {
|
|
59
|
+
if (!this.client) throw new _exceptionhelper.AppUnprocessableEntityException('S3 Client is not initialized yet');
|
|
60
|
+
try {
|
|
61
|
+
this.client.send(new _clients3.DeleteObjectCommand({
|
|
62
|
+
Bucket: this.BUCKET,
|
|
63
|
+
Key: path
|
|
64
|
+
}));
|
|
65
|
+
} catch (error) {
|
|
66
|
+
throw new _exceptionhelper.AppUnprocessableEntityException(`Failed to delete file ${path}: ${error?.message}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async isExists(path) {
|
|
70
|
+
if (!this.client) throw new _exceptionhelper.AppUnprocessableEntityException('S3 Client is not initialized yet');
|
|
71
|
+
let command = new _clients3.GetObjectCommand({
|
|
72
|
+
Bucket: this.BUCKET,
|
|
73
|
+
Key: path
|
|
74
|
+
});
|
|
75
|
+
try {
|
|
76
|
+
return await this.client.send(command), !0;
|
|
77
|
+
} catch (error) {
|
|
78
|
+
if (error?.name === 'NoSuchKey') return !1;
|
|
79
|
+
throw new _exceptionhelper.AppUnprocessableEntityException(`Failed to check if file exists ${path}: ${error?.message}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async move(oldPath, newPath) {
|
|
83
|
+
if (!this.client) throw new _exceptionhelper.AppUnprocessableEntityException('S3 Client is not initialized yet');
|
|
84
|
+
try {
|
|
85
|
+
return await this.client.send(new _clients3.CopyObjectCommand({
|
|
86
|
+
Bucket: this.BUCKET,
|
|
87
|
+
CopySource: `${this.BUCKET}/${oldPath}`,
|
|
88
|
+
Key: newPath
|
|
89
|
+
})), await this.client.send(new _clients3.DeleteObjectCommand({
|
|
90
|
+
Bucket: this.BUCKET,
|
|
91
|
+
Key: oldPath
|
|
92
|
+
})), !0;
|
|
93
|
+
} catch (error) {
|
|
94
|
+
return !1;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
async _getObjectStream(path) {
|
|
98
|
+
if (!this.client) throw new _exceptionhelper.AppUnprocessableEntityException('S3 Client is not initialized yet');
|
|
99
|
+
let command = new _clients3.GetObjectCommand({
|
|
100
|
+
Bucket: this.BUCKET,
|
|
101
|
+
Key: path
|
|
102
|
+
}), response = await this.client.send(command);
|
|
103
|
+
return {
|
|
104
|
+
stream: response.Body,
|
|
105
|
+
mimeType: response.ContentType || 'application/octet-stream'
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
async getBase64(path) {
|
|
109
|
+
if (!this.client) throw new _exceptionhelper.AppUnprocessableEntityException('S3 Client is not initialized yet');
|
|
110
|
+
try {
|
|
111
|
+
let { stream, mimeType } = await this._getObjectStream(path), chunks = [];
|
|
112
|
+
return new Promise((resolve, reject)=>{
|
|
113
|
+
stream.on('data', (chunk)=>chunks.push(chunk)), stream.on('end', ()=>{
|
|
114
|
+
let base64 = Buffer.concat(chunks).toString('base64');
|
|
115
|
+
resolve(`data:${mimeType};base64,${base64}`);
|
|
116
|
+
}), stream.on('error', reject);
|
|
117
|
+
});
|
|
118
|
+
} catch (error) {
|
|
119
|
+
throw new _exceptionhelper.AppUnprocessableEntityException(`Failed to get base64 for ${path}: ${error?.message}`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
};
|
|
@@ -1 +1,31 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: !0
|
|
4
|
+
}), Object.defineProperty(exports, "StorageContract", {
|
|
5
|
+
enumerable: !0,
|
|
6
|
+
get: function() {
|
|
7
|
+
return StorageContract;
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
let _exceptionhelper = require("../../helpers/exception.helper");
|
|
11
|
+
let StorageContract = class StorageContract {
|
|
12
|
+
expiresIn;
|
|
13
|
+
upload(path, file, expiresIn) {
|
|
14
|
+
throw new _exceptionhelper.AppUnprocessableEntityException('Method not implemented.');
|
|
15
|
+
}
|
|
16
|
+
get(path, ttl) {
|
|
17
|
+
throw new _exceptionhelper.AppUnprocessableEntityException('Method not implemented.');
|
|
18
|
+
}
|
|
19
|
+
isExists(path) {
|
|
20
|
+
throw new _exceptionhelper.AppUnprocessableEntityException('Method not implemented.');
|
|
21
|
+
}
|
|
22
|
+
move(oldPath, newPath) {
|
|
23
|
+
throw new _exceptionhelper.AppUnprocessableEntityException('Method not implemented.');
|
|
24
|
+
}
|
|
25
|
+
delete(path) {
|
|
26
|
+
throw new _exceptionhelper.AppUnprocessableEntityException('Method not implemented.');
|
|
27
|
+
}
|
|
28
|
+
getBase64(path) {
|
|
29
|
+
throw new _exceptionhelper.AppUnprocessableEntityException('Method not implemented.');
|
|
30
|
+
}
|
|
31
|
+
};
|
|
@@ -1 +1,32 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: !0
|
|
4
|
+
}), Object.defineProperty(exports, "StorageModule", {
|
|
5
|
+
enumerable: !0,
|
|
6
|
+
get: function() {
|
|
7
|
+
return StorageModule;
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
let _common = require("@nestjs/common"), _csvstorage = require("./csv.storage"), _excelstorage = require("./excel.storage"), _storageservice = require("./storage.service");
|
|
11
|
+
let StorageModule = class StorageModule {
|
|
12
|
+
};
|
|
13
|
+
StorageModule = function(decorators, target, key, desc) {
|
|
14
|
+
var d, c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
|
|
15
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
16
|
+
else for(var i = decorators.length - 1; i >= 0; i--)(d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
|
|
17
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
18
|
+
}([
|
|
19
|
+
(0, _common.Global)(),
|
|
20
|
+
(0, _common.Module)({
|
|
21
|
+
providers: [
|
|
22
|
+
_storageservice.StorageService,
|
|
23
|
+
_csvstorage.CsvStorage,
|
|
24
|
+
_excelstorage.ExcelService
|
|
25
|
+
],
|
|
26
|
+
exports: [
|
|
27
|
+
_storageservice.StorageService,
|
|
28
|
+
_csvstorage.CsvStorage,
|
|
29
|
+
_excelstorage.ExcelService
|
|
30
|
+
]
|
|
31
|
+
})
|
|
32
|
+
], StorageModule);
|
|
@@ -1 +1,59 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: !0
|
|
4
|
+
}), Object.defineProperty(exports, "StorageService", {
|
|
5
|
+
enumerable: !0,
|
|
6
|
+
get: function() {
|
|
7
|
+
return StorageService;
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
let _common = require("@nestjs/common"), _secretmanager = require("../secret-manager");
|
|
11
|
+
function _ts_metadata(k, v) {
|
|
12
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
13
|
+
}
|
|
14
|
+
let StorageService = class StorageService {
|
|
15
|
+
expiresIn;
|
|
16
|
+
driver;
|
|
17
|
+
constructor(){
|
|
18
|
+
(0, _secretmanager.getSecret)().then((secret)=>{
|
|
19
|
+
if ('s3' === secret.STORAGE_DRIVER) {
|
|
20
|
+
let { S3Storage } = require('./s3-storage');
|
|
21
|
+
this.driver = new S3Storage();
|
|
22
|
+
} else if ('minio' === secret.STORAGE_DRIVER) {
|
|
23
|
+
let { MinioStorage } = require('./minio.storage');
|
|
24
|
+
this.driver = new MinioStorage();
|
|
25
|
+
} else {
|
|
26
|
+
let { LocalStorageService } = require('./local.storage');
|
|
27
|
+
this.driver = new LocalStorageService();
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
upload(path, file, expiresIn) {
|
|
32
|
+
return this.driver.upload(path, file, expiresIn);
|
|
33
|
+
}
|
|
34
|
+
get(path, ttl) {
|
|
35
|
+
return this.driver.get(path, ttl);
|
|
36
|
+
}
|
|
37
|
+
delete(path) {
|
|
38
|
+
return this.driver.delete(path);
|
|
39
|
+
}
|
|
40
|
+
isExists(path) {
|
|
41
|
+
return this.driver.isExists(path);
|
|
42
|
+
}
|
|
43
|
+
getBase64(path) {
|
|
44
|
+
return this.driver.getBase64(path);
|
|
45
|
+
}
|
|
46
|
+
move(oldPath, newPath) {
|
|
47
|
+
return this.driver.move(oldPath, newPath);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
StorageService = function(decorators, target, key, desc) {
|
|
51
|
+
var d, c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
|
|
52
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
53
|
+
else for(var i = decorators.length - 1; i >= 0; i--)(d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
|
|
54
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
55
|
+
}([
|
|
56
|
+
(0, _common.Injectable)(),
|
|
57
|
+
_ts_metadata("design:type", Function),
|
|
58
|
+
_ts_metadata("design:paramtypes", [])
|
|
59
|
+
], StorageService);
|
|
@@ -1 +1,132 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: !0
|
|
4
|
+
});
|
|
5
|
+
var target = exports, all = {
|
|
6
|
+
get AppBadGatewayException () {
|
|
7
|
+
return AppBadGatewayException;
|
|
8
|
+
},
|
|
9
|
+
get AppBadRequestException () {
|
|
10
|
+
return AppBadRequestException;
|
|
11
|
+
},
|
|
12
|
+
get AppConflictException () {
|
|
13
|
+
return AppConflictException;
|
|
14
|
+
},
|
|
15
|
+
get AppForbiddenException () {
|
|
16
|
+
return AppForbiddenException;
|
|
17
|
+
},
|
|
18
|
+
get AppGatewayTimeoutException () {
|
|
19
|
+
return AppGatewayTimeoutException;
|
|
20
|
+
},
|
|
21
|
+
get AppInternalServerErrorException () {
|
|
22
|
+
return AppInternalServerErrorException;
|
|
23
|
+
},
|
|
24
|
+
get AppNotFoundException () {
|
|
25
|
+
return AppNotFoundException;
|
|
26
|
+
},
|
|
27
|
+
get AppServiceUnavailableException () {
|
|
28
|
+
return AppServiceUnavailableException;
|
|
29
|
+
},
|
|
30
|
+
get AppUnauthorizedException () {
|
|
31
|
+
return AppUnauthorizedException;
|
|
32
|
+
},
|
|
33
|
+
get AppUnprocessableEntityException () {
|
|
34
|
+
return AppUnprocessableEntityException;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
38
|
+
enumerable: !0,
|
|
39
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
40
|
+
});
|
|
41
|
+
let _common = require("@nestjs/common");
|
|
42
|
+
let AppBadRequestException = class AppBadRequestException extends _common.BadRequestException {
|
|
43
|
+
constructor(err){
|
|
44
|
+
super({
|
|
45
|
+
statusCode: 400,
|
|
46
|
+
message: 'Bad request',
|
|
47
|
+
errors: 'string' == typeof err ? {
|
|
48
|
+
error: err
|
|
49
|
+
} : Object.entries(err).reduce((acc, [key, value])=>({
|
|
50
|
+
...acc,
|
|
51
|
+
[key]: value
|
|
52
|
+
}), {})
|
|
53
|
+
}), this.message = ('string' == typeof err ? [
|
|
54
|
+
err
|
|
55
|
+
] : Object.values(err).flat()).join(', ');
|
|
56
|
+
}
|
|
57
|
+
has(str) {
|
|
58
|
+
return this.message.includes(str);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
let AppUnprocessableEntityException = class AppUnprocessableEntityException extends _common.UnprocessableEntityException {
|
|
62
|
+
constructor(message){
|
|
63
|
+
super({
|
|
64
|
+
statusCode: 422,
|
|
65
|
+
message: message || 'Unprocessable entity'
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
let AppNotFoundException = class AppNotFoundException extends _common.NotFoundException {
|
|
70
|
+
constructor(message){
|
|
71
|
+
super({
|
|
72
|
+
statusCode: 404,
|
|
73
|
+
message: message || 'Not found'
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
let AppForbiddenException = class AppForbiddenException extends _common.ForbiddenException {
|
|
78
|
+
constructor(message){
|
|
79
|
+
super({
|
|
80
|
+
statusCode: 403,
|
|
81
|
+
message: message || 'Forbidden'
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
let AppUnauthorizedException = class AppUnauthorizedException extends _common.UnauthorizedException {
|
|
86
|
+
constructor(message){
|
|
87
|
+
super({
|
|
88
|
+
statusCode: 401,
|
|
89
|
+
message: message || 'Unauthorized'
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
let AppConflictException = class AppConflictException extends _common.ConflictException {
|
|
94
|
+
constructor(message){
|
|
95
|
+
super({
|
|
96
|
+
statusCode: 409,
|
|
97
|
+
message: message || 'Conflict'
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
let AppBadGatewayException = class AppBadGatewayException extends _common.BadGatewayException {
|
|
102
|
+
constructor(message){
|
|
103
|
+
super({
|
|
104
|
+
statusCode: 502,
|
|
105
|
+
message: message || 'Bad gateway'
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
let AppGatewayTimeoutException = class AppGatewayTimeoutException extends _common.GatewayTimeoutException {
|
|
110
|
+
constructor(message){
|
|
111
|
+
super({
|
|
112
|
+
statusCode: 504,
|
|
113
|
+
message: message || 'Gateway timeout'
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
let AppInternalServerErrorException = class AppInternalServerErrorException extends _common.InternalServerErrorException {
|
|
118
|
+
constructor(message){
|
|
119
|
+
super({
|
|
120
|
+
statusCode: 500,
|
|
121
|
+
message: message || 'Internal server error'
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
let AppServiceUnavailableException = class AppServiceUnavailableException extends _common.ServiceUnavailableException {
|
|
126
|
+
constructor(message){
|
|
127
|
+
super({
|
|
128
|
+
statusCode: 503,
|
|
129
|
+
message: message || 'Service unavailable'
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
};
|