drapcode-utility 2.7.3 → 2.7.4-sandbox.1
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/build/aws/aws-util.d.ts +6 -0
- package/build/aws/aws-util.d.ts.map +1 -0
- package/build/aws/aws-util.js +34 -0
- package/build/aws/aws-util.js.map +1 -0
- package/build/aws/encryption/KMS.d.ts +9 -0
- package/build/aws/encryption/KMS.d.ts.map +1 -0
- package/build/aws/encryption/KMS.js +65 -0
- package/build/aws/encryption/KMS.js.map +1 -0
- package/build/{encryption → aws/encryption}/crypt.d.ts +1 -0
- package/build/aws/encryption/crypt.d.ts.map +1 -0
- package/build/{encryption → aws/encryption}/crypt.js +25 -36
- package/build/aws/encryption/crypt.js.map +1 -0
- package/build/{encryption → aws/encryption}/file.d.ts +2 -1
- package/build/aws/encryption/file.d.ts.map +1 -0
- package/build/{encryption → aws/encryption}/file.js +2 -3
- package/build/aws/encryption/file.js.map +1 -0
- package/build/{encryption → aws/encryption}/index.d.ts +4 -3
- package/build/aws/encryption/index.d.ts.map +1 -0
- package/build/{encryption → aws/encryption}/index.js +41 -41
- package/build/aws/encryption/index.js.map +1 -0
- package/build/{encryption → aws/encryption}/utility.d.ts +1 -0
- package/build/aws/encryption/utility.d.ts.map +1 -0
- package/build/{encryption → aws/encryption}/utility.js +3 -2
- package/build/aws/encryption/utility.js.map +1 -0
- package/build/aws/model.d.ts +30 -0
- package/build/aws/model.d.ts.map +1 -0
- package/build/{encryption → aws}/model.js +1 -0
- package/build/aws/model.js.map +1 -0
- package/build/aws/s3-util.d.ts +36 -0
- package/build/aws/s3-util.d.ts.map +1 -0
- package/build/aws/s3-util.js +198 -0
- package/build/aws/s3-util.js.map +1 -0
- package/build/errors/app-error.d.ts +17 -4
- package/build/errors/app-error.d.ts.map +1 -0
- package/build/errors/app-error.js +184 -6
- package/build/errors/app-error.js.map +1 -0
- package/build/errors/async-handler.d.ts +3 -0
- package/build/errors/async-handler.d.ts.map +1 -0
- package/build/errors/async-handler.js +9 -0
- package/build/errors/async-handler.js.map +1 -0
- package/build/errors/axios-error.d.ts +2 -1
- package/build/errors/axios-error.d.ts.map +1 -0
- package/build/errors/axios-error.js +12 -8
- package/build/errors/axios-error.js.map +1 -0
- package/build/errors/bad-request-error.d.ts +2 -1
- package/build/errors/bad-request-error.d.ts.map +1 -0
- package/build/errors/bad-request-error.js +1 -0
- package/build/errors/bad-request-error.js.map +1 -0
- package/build/errors/custom-error.d.ts +1 -0
- package/build/errors/custom-error.d.ts.map +1 -0
- package/build/errors/custom-error.js +1 -0
- package/build/errors/custom-error.js.map +1 -0
- package/build/errors/error-classes.d.ts +23 -0
- package/build/errors/error-classes.d.ts.map +1 -0
- package/build/errors/error-classes.js +87 -0
- package/build/errors/error-classes.js.map +1 -0
- package/build/errors/error-codes.d.ts +47 -0
- package/build/errors/error-codes.d.ts.map +1 -0
- package/build/errors/error-codes.js +78 -0
- package/build/errors/error-codes.js.map +1 -0
- package/build/errors/error-obj.d.ts +10 -0
- package/build/errors/error-obj.d.ts.map +1 -0
- package/build/errors/error-obj.js +55 -0
- package/build/errors/error-obj.js.map +1 -0
- package/build/errors/get-error-details.d.ts +11 -0
- package/build/errors/get-error-details.d.ts.map +1 -0
- package/build/errors/get-error-details.js +28 -0
- package/build/errors/get-error-details.js.map +1 -0
- package/build/errors/not-found.d.ts +2 -1
- package/build/errors/not-found.d.ts.map +1 -0
- package/build/errors/not-found.js +3 -2
- package/build/errors/not-found.js.map +1 -0
- package/build/errors/wrap-error.d.ts +9 -0
- package/build/errors/wrap-error.d.ts.map +1 -0
- package/build/errors/wrap-error.js +17 -0
- package/build/errors/wrap-error.js.map +1 -0
- package/build/format-fields/index.d.ts +1 -0
- package/build/format-fields/index.d.ts.map +1 -0
- package/build/format-fields/index.js +13 -13
- package/build/format-fields/index.js.map +1 -0
- package/build/index.d.ts +25 -21
- package/build/index.d.ts.map +1 -0
- package/build/index.js +13 -7
- package/build/index.js.map +1 -0
- package/build/middlewares/redis/request-log.d.ts +1 -0
- package/build/middlewares/redis/request-log.d.ts.map +1 -0
- package/build/middlewares/redis/request-log.js +3 -2
- package/build/middlewares/redis/request-log.js.map +1 -0
- package/build/query/queryBuilder.d.ts +1 -0
- package/build/query/queryBuilder.d.ts.map +1 -0
- package/build/query/queryBuilder.js +66 -129
- package/build/query/queryBuilder.js.map +1 -0
- package/build/utils/check-error.d.ts +1 -0
- package/build/utils/check-error.d.ts.map +1 -0
- package/build/utils/check-error.js +14 -15
- package/build/utils/check-error.js.map +1 -0
- package/build/utils/common-util.d.ts +2 -1
- package/build/utils/common-util.d.ts.map +1 -0
- package/build/utils/common-util.js +46 -47
- package/build/utils/common-util.js.map +1 -0
- package/build/utils/date-util.d.ts +1 -0
- package/build/utils/date-util.d.ts.map +1 -0
- package/build/utils/date-util.js +59 -60
- package/build/utils/date-util.js.map +1 -0
- package/build/utils/file-util.d.ts +9 -0
- package/build/utils/file-util.d.ts.map +1 -0
- package/build/utils/file-util.js +120 -9
- package/build/utils/file-util.js.map +1 -0
- package/build/utils/prepare-query.d.ts +1 -0
- package/build/utils/prepare-query.d.ts.map +1 -0
- package/build/utils/prepare-query.js +15 -17
- package/build/utils/prepare-query.js.map +1 -0
- package/build/utils/project-util.d.ts +2 -1
- package/build/utils/project-util.d.ts.map +1 -0
- package/build/utils/project-util.js +45 -50
- package/build/utils/project-util.js.map +1 -0
- package/build/utils/query-parser.d.ts +1 -1
- package/build/utils/query-parser.d.ts.map +1 -0
- package/build/utils/query-parser.js +6 -568
- package/build/utils/query-parser.js.map +1 -0
- package/build/utils/query-utils.d.ts +1 -0
- package/build/utils/query-utils.d.ts.map +1 -0
- package/build/utils/query-utils.js +46 -50
- package/build/utils/query-utils.js.map +1 -0
- package/build/utils/rest-client.d.ts +1 -0
- package/build/utils/rest-client.d.ts.map +1 -0
- package/build/utils/rest-client.js +88 -122
- package/build/utils/rest-client.js.map +1 -0
- package/build/utils/token.d.ts +1 -0
- package/build/utils/token.d.ts.map +1 -0
- package/build/utils/token.js +4 -3
- package/build/utils/token.js.map +1 -0
- package/build/utils/util.d.ts +2 -1
- package/build/utils/util.d.ts.map +1 -0
- package/build/utils/util.js +340 -392
- package/build/utils/util.js.map +1 -0
- package/build/utils/uuid-generator.d.ts +1 -0
- package/build/utils/uuid-generator.d.ts.map +1 -0
- package/build/utils/uuid-generator.js +9 -8
- package/build/utils/uuid-generator.js.map +1 -0
- package/package.json +7 -6
- package/build/encryption/KMS.d.ts +0 -8
- package/build/encryption/KMS.js +0 -67
- package/build/encryption/model.d.ts +0 -17
- package/build/middlewares/error-logger.d.ts +0 -3
- package/build/middlewares/error-logger.js +0 -74
- package/build/utils/s3-util.d.ts +0 -36
- package/build/utils/s3-util.js +0 -275
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { S3Client } from '@aws-sdk/client-s3';
|
|
2
|
+
import { S3Config, Encryption, AWSConfig } from './model';
|
|
3
|
+
export declare const fileUploadToS3: (files: any, s3Client: S3Client, s3Config: S3Config, publicS3Client: S3Client, publicS3Config: S3Config, isGenerateIcons: boolean, encryption: Encryption, options?: {}, encrypted?: boolean) => Promise<{
|
|
4
|
+
originalname: any;
|
|
5
|
+
mimetype: any;
|
|
6
|
+
size: any;
|
|
7
|
+
key: string | undefined;
|
|
8
|
+
contentType: string;
|
|
9
|
+
smallIcon: string | null;
|
|
10
|
+
mediumIcon: string | null;
|
|
11
|
+
largeIcon: string | null;
|
|
12
|
+
} | {
|
|
13
|
+
originalname: any;
|
|
14
|
+
mimetype: any;
|
|
15
|
+
size: any;
|
|
16
|
+
key: string | undefined;
|
|
17
|
+
contentType: string;
|
|
18
|
+
smallIcon: string | null;
|
|
19
|
+
mediumIcon: string | null;
|
|
20
|
+
largeIcon: string | null;
|
|
21
|
+
}[] | null>;
|
|
22
|
+
export declare const deleteS3FromKey: (config: AWSConfig, bucket: string, key: string) => Promise<void>;
|
|
23
|
+
export declare const loadObjectFromS3Key: (config: AWSConfig, bucket: string, key: string) => Promise<import("@smithy/types").StreamingBlobPayloadOutputTypes>;
|
|
24
|
+
export declare const createSingedUrl: (config: AWSConfig, bucket: string, key: string) => Promise<string | {
|
|
25
|
+
code: number;
|
|
26
|
+
error: string;
|
|
27
|
+
}>;
|
|
28
|
+
export declare const listObjectsFromS3: (config: AWSConfig, params: any) => Promise<import("@aws-sdk/client-s3").ListObjectsV2CommandOutput | {
|
|
29
|
+
code: number;
|
|
30
|
+
error: string;
|
|
31
|
+
}>;
|
|
32
|
+
export declare const updateSaveObjectToS3: (config: AWSConfig, params: any) => Promise<import("@aws-sdk/client-s3").PutObjectCommandOutput | {
|
|
33
|
+
code: number;
|
|
34
|
+
error: string;
|
|
35
|
+
}>;
|
|
36
|
+
//# sourceMappingURL=s3-util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s3-util.d.ts","sourceRoot":"","sources":["../../src/aws/s3-util.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,QAAQ,EAKT,MAAM,oBAAoB,CAAC;AAS5B,OAAO,EAAY,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAKpE,eAAO,MAAM,cAAc,GACzB,OAAO,GAAG,EACV,UAAU,QAAQ,EAClB,UAAU,QAAQ,EAClB,gBAAgB,QAAQ,EACxB,gBAAgB,QAAQ,EACxB,iBAAiB,OAAO,EACxB,YAAY,UAAU,EACtB,YAAY,EACZ,mBAAiB;;;;;;;;;;;;;;;;;;WAiClB,CAAC;AAqJF,eAAO,MAAM,eAAe,GAAU,QAAQ,SAAS,EAAE,QAAQ,MAAM,EAAE,KAAK,MAAM,kBAUnF,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAU,QAAQ,SAAS,EAAE,QAAQ,MAAM,EAAE,KAAK,MAAM,qEAcvF,CAAC;AAEF,eAAO,MAAM,eAAe,GAAU,QAAQ,SAAS,EAAE,QAAQ,MAAM,EAAE,KAAK,MAAM;;;EAQnF,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAU,QAAQ,SAAS,EAAE,QAAQ,GAAG;;;EAQrE,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAU,QAAQ,SAAS,EAAE,QAAQ,GAAG;;;EASxE,CAAC"}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.updateSaveObjectToS3 = exports.listObjectsFromS3 = exports.createSingedUrl = exports.loadObjectFromS3Key = exports.deleteS3FromKey = exports.fileUploadToS3 = void 0;
|
|
7
|
+
const drapcode_constant_1 = require("drapcode-constant");
|
|
8
|
+
const drapcode_logger_1 = require("drapcode-logger");
|
|
9
|
+
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
10
|
+
const lib_storage_1 = require("@aws-sdk/lib-storage");
|
|
11
|
+
const s3_request_presigner_1 = require("@aws-sdk/s3-request-presigner");
|
|
12
|
+
const fs_1 = __importDefault(require("fs"));
|
|
13
|
+
const mime_types_1 = __importDefault(require("mime-types"));
|
|
14
|
+
const uuid_1 = require("uuid");
|
|
15
|
+
const encryption_1 = require("./encryption");
|
|
16
|
+
const file_util_1 = require("../utils/file-util");
|
|
17
|
+
const util_1 = require("../utils/util");
|
|
18
|
+
const aws_util_1 = require("./aws-util");
|
|
19
|
+
const fileUploadToS3 = async (files, s3Client, s3Config, publicS3Client, publicS3Config, isGenerateIcons, encryption, options = {}, encrypted = false) => {
|
|
20
|
+
const privateConfig = { s3Client, s3Config };
|
|
21
|
+
const publicConfig = { publicS3Client, publicS3Config };
|
|
22
|
+
const encryptConfig = { encryption, encrypted };
|
|
23
|
+
if (Array.isArray(files)) {
|
|
24
|
+
const fileOptions = [];
|
|
25
|
+
for (const file of files) {
|
|
26
|
+
const fileObj = await processSingleFileUploadToS3(file, privateConfig, publicConfig, encryptConfig, isGenerateIcons, options);
|
|
27
|
+
if (fileObj) {
|
|
28
|
+
fileOptions.push(fileObj);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return fileOptions;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
return processSingleFileUploadToS3(files, privateConfig, publicConfig, encryptConfig, isGenerateIcons, options);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
exports.fileUploadToS3 = fileUploadToS3;
|
|
38
|
+
const processSingleFileUploadToS3 = async (file, privateConfig, publicConfig, encryptConfig, isGenerateIcons, options = {}) => {
|
|
39
|
+
const { s3Config } = privateConfig;
|
|
40
|
+
const s3Key = s3Config.key;
|
|
41
|
+
const fileSlug = (0, util_1.slugifyFileName)(file.originalname);
|
|
42
|
+
if (s3Config.append) {
|
|
43
|
+
s3Config.key = `${s3Key}/${(0, uuid_1.v4)()}/${fileSlug}`;
|
|
44
|
+
}
|
|
45
|
+
return await processFileUploadToS3(file, privateConfig, publicConfig, encryptConfig, isGenerateIcons, options);
|
|
46
|
+
};
|
|
47
|
+
const processFileUploadToS3 = async (file, privateConfig, publicConfig, encryptConfig, isGenerateIcons, options = {}) => {
|
|
48
|
+
try {
|
|
49
|
+
const { s3Config, s3Client } = privateConfig;
|
|
50
|
+
const { publicS3Client, publicS3Config } = publicConfig;
|
|
51
|
+
const { encryption, encrypted } = encryptConfig;
|
|
52
|
+
const contentType = mime_types_1.default.lookup(file.originalname) || '';
|
|
53
|
+
const { acl, key, bucket } = s3Config;
|
|
54
|
+
let params = null;
|
|
55
|
+
let filePath = file.path;
|
|
56
|
+
if (encrypted) {
|
|
57
|
+
filePath = await (0, encryption_1.cryptFile)(file.path, encryption, false);
|
|
58
|
+
}
|
|
59
|
+
params = {
|
|
60
|
+
Bucket: bucket,
|
|
61
|
+
ACL: acl,
|
|
62
|
+
Key: key,
|
|
63
|
+
Body: fs_1.default.createReadStream(filePath),
|
|
64
|
+
ContentType: contentType,
|
|
65
|
+
...options,
|
|
66
|
+
};
|
|
67
|
+
const parallelUploads3 = new lib_storage_1.Upload({ client: s3Client, params });
|
|
68
|
+
const data = await parallelUploads3.done();
|
|
69
|
+
const { smallIcon, mediumIcon, largeIcon } = await handleIconUpload(file, contentType, publicS3Client, publicS3Config, isGenerateIcons, key, options);
|
|
70
|
+
if (data) {
|
|
71
|
+
fs_1.default.unlinkSync(filePath);
|
|
72
|
+
}
|
|
73
|
+
const { originalname, mimetype, size } = file;
|
|
74
|
+
return {
|
|
75
|
+
originalname,
|
|
76
|
+
mimetype,
|
|
77
|
+
size,
|
|
78
|
+
key: data.Key,
|
|
79
|
+
contentType,
|
|
80
|
+
smallIcon,
|
|
81
|
+
mediumIcon,
|
|
82
|
+
largeIcon,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
drapcode_logger_1.logger.error(`Error uploading file to S3: ${error}`);
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
const handleIconUpload = async (file, contentType, publicS3Client, publicS3Config, isGenerateIcons, key, options = {}) => {
|
|
91
|
+
const { path: filePath, size: fileSize } = file;
|
|
92
|
+
const iconSizes = [200, 300, 500];
|
|
93
|
+
const iconLabels = ['small', 'medium', 'large'];
|
|
94
|
+
try {
|
|
95
|
+
if (isGenerateIcons &&
|
|
96
|
+
fileSize < 157286400 && //150mb
|
|
97
|
+
[...drapcode_constant_1.imageMimeTypes, 'application/pdf', 'image/gif'].includes(contentType)) {
|
|
98
|
+
const iconFiles = await (0, file_util_1.generateDynamicIcons)(filePath, iconSizes, contentType);
|
|
99
|
+
const { bucket, acl } = publicS3Config;
|
|
100
|
+
const iconUploads = iconFiles.map(async (iconFilePath, index) => {
|
|
101
|
+
const iconLabel = iconLabels[index];
|
|
102
|
+
const iconKey = `${key}/icons/${(0, uuid_1.v4)()}_${iconLabel}.png`;
|
|
103
|
+
const iconParams = {
|
|
104
|
+
Bucket: bucket,
|
|
105
|
+
ACL: acl,
|
|
106
|
+
Key: iconKey,
|
|
107
|
+
Body: fs_1.default.createReadStream(iconFilePath),
|
|
108
|
+
ContentType: 'image/png',
|
|
109
|
+
...options,
|
|
110
|
+
};
|
|
111
|
+
const iconUpload = new lib_storage_1.Upload({
|
|
112
|
+
client: publicS3Client,
|
|
113
|
+
params: iconParams,
|
|
114
|
+
});
|
|
115
|
+
const iconData = await iconUpload.done();
|
|
116
|
+
fs_1.default.unlinkSync(iconFilePath);
|
|
117
|
+
return iconData.Key;
|
|
118
|
+
});
|
|
119
|
+
const [smallKey, mediumKey, largeKey] = await Promise.all(iconUploads);
|
|
120
|
+
return {
|
|
121
|
+
smallIcon: generateS3IconUrl(bucket, smallKey),
|
|
122
|
+
mediumIcon: generateS3IconUrl(bucket, mediumKey),
|
|
123
|
+
largeIcon: generateS3IconUrl(bucket, largeKey),
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
return (0, file_util_1.generateStaticIcons)(contentType);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
catch (iconError) {
|
|
131
|
+
drapcode_logger_1.logger.error(`Error generating or uploading icons: ${iconError}`);
|
|
132
|
+
return (0, file_util_1.generateStaticIcons)(contentType);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
const generateS3IconUrl = (bucket, key) => {
|
|
136
|
+
if (!key)
|
|
137
|
+
return null;
|
|
138
|
+
return `https://${bucket}.s3.amazonaws.com/${key}`;
|
|
139
|
+
};
|
|
140
|
+
const deleteS3FromKey = async (config, bucket, key) => {
|
|
141
|
+
const params = {
|
|
142
|
+
Bucket: bucket,
|
|
143
|
+
Key: key,
|
|
144
|
+
};
|
|
145
|
+
const command = new client_s3_1.DeleteObjectCommand(params);
|
|
146
|
+
const s3client = (0, aws_util_1.createS3Client)(config);
|
|
147
|
+
if (!s3client)
|
|
148
|
+
throw new Error('Missing or invalid information');
|
|
149
|
+
await s3client.send(command);
|
|
150
|
+
};
|
|
151
|
+
exports.deleteS3FromKey = deleteS3FromKey;
|
|
152
|
+
const loadObjectFromS3Key = async (config, bucket, key) => {
|
|
153
|
+
const s3client = (0, aws_util_1.createS3Client)(config);
|
|
154
|
+
if (!s3client)
|
|
155
|
+
throw new Error('Missing or invalid information');
|
|
156
|
+
const s3Params = {
|
|
157
|
+
Bucket: bucket,
|
|
158
|
+
Key: key,
|
|
159
|
+
};
|
|
160
|
+
const { Body } = await s3client.send(new client_s3_1.GetObjectCommand(s3Params));
|
|
161
|
+
if (!Body) {
|
|
162
|
+
throw new Error(`S3 object not found or empty: s3://${bucket}/${key}`);
|
|
163
|
+
}
|
|
164
|
+
return Body;
|
|
165
|
+
};
|
|
166
|
+
exports.loadObjectFromS3Key = loadObjectFromS3Key;
|
|
167
|
+
const createSingedUrl = async (config, bucket, key) => {
|
|
168
|
+
const s3Client = (0, aws_util_1.createS3Client)(config);
|
|
169
|
+
if (!s3Client) {
|
|
170
|
+
return { code: 500, error: 'Failed to initialize S3 client' };
|
|
171
|
+
}
|
|
172
|
+
const command = new client_s3_1.GetObjectCommand({ Bucket: bucket, Key: key });
|
|
173
|
+
const signedUrl = await (0, s3_request_presigner_1.getSignedUrl)(s3Client, command, { expiresIn: 3600 });
|
|
174
|
+
return signedUrl;
|
|
175
|
+
};
|
|
176
|
+
exports.createSingedUrl = createSingedUrl;
|
|
177
|
+
const listObjectsFromS3 = async (config, params) => {
|
|
178
|
+
const s3Client = (0, aws_util_1.createS3Client)(config);
|
|
179
|
+
if (!s3Client) {
|
|
180
|
+
return { code: 500, error: 'Failed to initialize S3 client' };
|
|
181
|
+
}
|
|
182
|
+
const command = new client_s3_1.ListObjectsV2Command(params);
|
|
183
|
+
const res = await s3Client.send(command);
|
|
184
|
+
return res;
|
|
185
|
+
};
|
|
186
|
+
exports.listObjectsFromS3 = listObjectsFromS3;
|
|
187
|
+
const updateSaveObjectToS3 = async (config, params) => {
|
|
188
|
+
const s3Client = (0, aws_util_1.createS3Client)(config);
|
|
189
|
+
if (!s3Client) {
|
|
190
|
+
return { code: 500, error: 'Failed to initialize S3 client' };
|
|
191
|
+
}
|
|
192
|
+
const command = new client_s3_1.PutObjectCommand(params);
|
|
193
|
+
// eslint-disable-next-line no-undef
|
|
194
|
+
const uploadedImage = await s3Client.send(command);
|
|
195
|
+
return uploadedImage;
|
|
196
|
+
};
|
|
197
|
+
exports.updateSaveObjectToS3 = updateSaveObjectToS3;
|
|
198
|
+
//# sourceMappingURL=s3-util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s3-util.js","sourceRoot":"","sources":["../../src/aws/s3-util.ts"],"names":[],"mappings":";;;;;;AAAA,yDAAmD;AACnD,qDAAyC;AAEzC,kDAM4B;AAC5B,sDAA8C;AAC9C,wEAA6D;AAE7D,4CAAoB;AACpB,4DAA8B;AAC9B,+BAAoC;AAEpC,6CAAyC;AAEzC,kDAA+E;AAC/E,wCAAgD;AAChD,yCAA4C;AAErC,MAAM,cAAc,GAAG,KAAK,EACjC,KAAU,EACV,QAAkB,EAClB,QAAkB,EAClB,cAAwB,EACxB,cAAwB,EACxB,eAAwB,EACxB,UAAsB,EACtB,OAAO,GAAG,EAAE,EACZ,SAAS,GAAG,KAAK,EACjB,EAAE;IACF,MAAM,aAAa,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;IAC7C,MAAM,YAAY,GAAG,EAAE,cAAc,EAAE,cAAc,EAAE,CAAC;IACxD,MAAM,aAAa,GAAG,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;IAEhD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,WAAW,GAAG,EAAE,CAAC;QACvB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,OAAO,GAAG,MAAM,2BAA2B,CAC/C,IAAI,EACJ,aAAa,EACb,YAAY,EACZ,aAAa,EACb,eAAe,EACf,OAAO,CACR,CAAC;YA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
import { ErrorCode } from './error-codes';
|
|
2
|
+
export interface AppErrorOptions {
|
|
3
|
+
message?: string;
|
|
4
|
+
code?: ErrorCode | string;
|
|
5
|
+
statusCode?: number;
|
|
6
|
+
details?: unknown;
|
|
7
|
+
cause?: unknown;
|
|
8
|
+
isOperational?: boolean;
|
|
9
|
+
}
|
|
1
10
|
export declare class AppError extends Error {
|
|
2
|
-
|
|
3
|
-
statusCode: number;
|
|
4
|
-
|
|
5
|
-
|
|
11
|
+
readonly code: string;
|
|
12
|
+
readonly statusCode: number;
|
|
13
|
+
readonly details: unknown;
|
|
14
|
+
readonly cause: unknown;
|
|
15
|
+
readonly isOperational: boolean;
|
|
16
|
+
constructor(optionsOrMessage?: AppErrorOptions | string | null, legacyStatusCode?: number, legacyCode?: string);
|
|
6
17
|
}
|
|
18
|
+
export declare function normalizeError(error: unknown): AppError;
|
|
19
|
+
//# sourceMappingURL=app-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-error.d.ts","sourceRoot":"","sources":["../../src/errors/app-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,SAAS,EAAiB,MAAM,eAAe,CAAC;AAGrE,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,qBAAa,QAAS,SAAQ,KAAK;IACjC,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,SAAgB,OAAO,EAAE,OAAO,CAAC;IACjC,SAAgB,KAAK,EAAE,OAAO,CAAC;IAC/B,SAAgB,aAAa,EAAE,OAAO,CAAC;gBAGrC,gBAAgB,GAAE,eAAe,GAAG,MAAM,GAAG,IAAW,EACxD,gBAAgB,SAAM,EACtB,UAAU,GAAE,MAAgD;CA0C/D;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,QAAQ,CA6GvD"}
|
|
@@ -1,14 +1,192 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AppError = void 0;
|
|
4
|
+
exports.normalizeError = normalizeError;
|
|
5
|
+
const error_codes_1 = require("./error-codes");
|
|
6
|
+
const get_error_details_1 = require("./get-error-details");
|
|
4
7
|
class AppError extends Error {
|
|
5
|
-
constructor(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
constructor(optionsOrMessage = null, legacyStatusCode = 500, legacyCode = error_codes_1.ErrorCodes.SYSTEM.INTERNAL_SERVER_ERROR) {
|
|
9
|
+
let options;
|
|
10
|
+
if (typeof optionsOrMessage === 'object' && optionsOrMessage !== null) {
|
|
11
|
+
options = optionsOrMessage;
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
options = {
|
|
15
|
+
message: optionsOrMessage ?? undefined,
|
|
16
|
+
statusCode: legacyStatusCode,
|
|
17
|
+
code: legacyCode,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const { message, code = error_codes_1.ErrorCodes.SYSTEM.INTERNAL_SERVER_ERROR, statusCode = 500, details = null, cause = null, isOperational = true, } = options;
|
|
21
|
+
const finalMessage = message ||
|
|
22
|
+
error_codes_1.ErrorMessages[code] ||
|
|
23
|
+
// ErrorMessages[ErrorCodes.SYSTEM.INTERNAL_SERVER_ERROR] ||
|
|
24
|
+
'Something went wrong. Please try again later.';
|
|
25
|
+
super(finalMessage);
|
|
26
|
+
this.name = this.constructor.name;
|
|
27
|
+
this.code = code;
|
|
8
28
|
this.statusCode = statusCode;
|
|
9
|
-
this.
|
|
10
|
-
this.
|
|
11
|
-
|
|
29
|
+
this.details = details;
|
|
30
|
+
this.cause = cause;
|
|
31
|
+
this.isOperational = isOperational;
|
|
32
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
33
|
+
Error.captureStackTrace?.(this, this.constructor);
|
|
12
34
|
}
|
|
13
35
|
}
|
|
14
36
|
exports.AppError = AppError;
|
|
37
|
+
function normalizeError(error) {
|
|
38
|
+
if (error instanceof AppError) {
|
|
39
|
+
return error;
|
|
40
|
+
}
|
|
41
|
+
const err = error;
|
|
42
|
+
if (err?.name === 'ValidationError') {
|
|
43
|
+
return new AppError({
|
|
44
|
+
code: error_codes_1.ErrorCodes.VALIDATION.INVALID_VALUE,
|
|
45
|
+
statusCode: 400,
|
|
46
|
+
message: 'The provided data is invalid.',
|
|
47
|
+
details: (0, get_error_details_1.getMongooseValidationDetails)(err),
|
|
48
|
+
cause: error,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
if (err?.name === 'CastError') {
|
|
52
|
+
return new AppError({
|
|
53
|
+
code: error_codes_1.ErrorCodes.VALIDATION.INVALID_FORMAT,
|
|
54
|
+
statusCode: 400,
|
|
55
|
+
message: `Invalid value provided for ${err.path}.`,
|
|
56
|
+
details: {
|
|
57
|
+
field: err.path,
|
|
58
|
+
value: err.value,
|
|
59
|
+
},
|
|
60
|
+
cause: error,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
if (err?.code === 11000) {
|
|
64
|
+
return new AppError({
|
|
65
|
+
code: error_codes_1.ErrorCodes.DATABASE.DUPLICATE_KEY,
|
|
66
|
+
statusCode: 409,
|
|
67
|
+
message: 'A record with the provided information already exists.',
|
|
68
|
+
details: (0, get_error_details_1.getDuplicateKeyDetails)(err),
|
|
69
|
+
cause: error,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
if (err?.name === 'VersionError') {
|
|
73
|
+
return new AppError({
|
|
74
|
+
code: error_codes_1.ErrorCodes.DATABASE.QUERY_FAILED,
|
|
75
|
+
statusCode: 409,
|
|
76
|
+
message: 'The record was modified by another request.',
|
|
77
|
+
cause: error,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
if (err?.name === 'TokenExpiredError') {
|
|
81
|
+
return new AppError({
|
|
82
|
+
code: error_codes_1.ErrorCodes.AUTH.TOKEN_EXPIRED,
|
|
83
|
+
statusCode: 401,
|
|
84
|
+
message: 'Your session has expired. Please log in again.',
|
|
85
|
+
cause: error,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
if (err?.name === 'JsonWebTokenError') {
|
|
89
|
+
return new AppError({
|
|
90
|
+
code: error_codes_1.ErrorCodes.AUTH.INVALID_TOKEN,
|
|
91
|
+
statusCode: 401,
|
|
92
|
+
message: 'The authentication token is invalid.',
|
|
93
|
+
cause: error,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
if (err?.isAxiosError) {
|
|
97
|
+
return normalizeAxiosError(err);
|
|
98
|
+
}
|
|
99
|
+
if (err?.name === 'MulterError') {
|
|
100
|
+
return normalizeMulterError(err);
|
|
101
|
+
}
|
|
102
|
+
if (err?.code === 'ETIMEDOUT' || err?.code === 'ECONNABORTED') {
|
|
103
|
+
return new AppError({
|
|
104
|
+
code: error_codes_1.ErrorCodes.API.REQUEST_TIMEOUT,
|
|
105
|
+
statusCode: 504,
|
|
106
|
+
message: 'The request timed out. Please try again later.',
|
|
107
|
+
cause: error,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
if (err?.name === 'MongoServerSelectionError' || err?.name === 'MongoNetworkError') {
|
|
111
|
+
return new AppError({
|
|
112
|
+
code: error_codes_1.ErrorCodes.DATABASE.CONNECTION_FAILED,
|
|
113
|
+
statusCode: 503,
|
|
114
|
+
message: 'The database service is currently unavailable.',
|
|
115
|
+
cause: error,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
if (Number.isInteger(err?.statusCode) && err.statusCode >= 400 && err.statusCode < 600) {
|
|
119
|
+
return new AppError({
|
|
120
|
+
code: err.code || error_codes_1.ErrorCodes.API.INVALID_REQUEST,
|
|
121
|
+
statusCode: err.statusCode,
|
|
122
|
+
message: err.message,
|
|
123
|
+
cause: error,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return new AppError({
|
|
127
|
+
code: error_codes_1.ErrorCodes.SYSTEM.INTERNAL_SERVER_ERROR,
|
|
128
|
+
statusCode: 500,
|
|
129
|
+
message: 'Something went wrong. Please try again later.',
|
|
130
|
+
cause: error,
|
|
131
|
+
isOperational: false,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
function normalizeAxiosError(error) {
|
|
135
|
+
const status = error.response?.status;
|
|
136
|
+
if (status === 401) {
|
|
137
|
+
return new AppError({
|
|
138
|
+
code: error_codes_1.ErrorCodes.AUTH.INVALID_TOKEN,
|
|
139
|
+
statusCode: 401,
|
|
140
|
+
message: 'Authentication failed while communicating with the external service.',
|
|
141
|
+
cause: error,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
if (status === 404) {
|
|
145
|
+
return new AppError({
|
|
146
|
+
code: error_codes_1.ErrorCodes.RESOURCE.RESOURCE_NOT_FOUND,
|
|
147
|
+
statusCode: 404,
|
|
148
|
+
message: 'The requested external resource was not found.',
|
|
149
|
+
cause: error,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
if (status >= 500) {
|
|
153
|
+
return new AppError({
|
|
154
|
+
code: error_codes_1.ErrorCodes.API.EXTERNAL_SERVICE_FAILED,
|
|
155
|
+
statusCode: 502,
|
|
156
|
+
message: 'The external service is currently unavailable.',
|
|
157
|
+
cause: error,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
return new AppError({
|
|
161
|
+
code: error_codes_1.ErrorCodes.API.EXTERNAL_SERVICE_FAILED,
|
|
162
|
+
statusCode: 502,
|
|
163
|
+
message: 'The external service could not process the request.',
|
|
164
|
+
cause: error,
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
function normalizeMulterError(error) {
|
|
168
|
+
switch (error.code) {
|
|
169
|
+
case 'LIMIT_FILE_SIZE':
|
|
170
|
+
return new AppError({
|
|
171
|
+
code: error_codes_1.ErrorCodes.FILE.TOO_LARGE,
|
|
172
|
+
statusCode: 413,
|
|
173
|
+
message: 'The uploaded file is too large.',
|
|
174
|
+
cause: error,
|
|
175
|
+
});
|
|
176
|
+
case 'LIMIT_UNEXPECTED_FILE':
|
|
177
|
+
return new AppError({
|
|
178
|
+
code: error_codes_1.ErrorCodes.FILE.INVALID_FORMAT,
|
|
179
|
+
statusCode: 400,
|
|
180
|
+
message: 'An unexpected file was uploaded.',
|
|
181
|
+
cause: error,
|
|
182
|
+
});
|
|
183
|
+
default:
|
|
184
|
+
return new AppError({
|
|
185
|
+
code: error_codes_1.ErrorCodes.FILE.UPLOAD_FAILED,
|
|
186
|
+
statusCode: 400,
|
|
187
|
+
message: 'The file could not be uploaded.',
|
|
188
|
+
cause: error,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=app-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-error.js","sourceRoot":"","sources":["../../src/errors/app-error.ts"],"names":[],"mappings":";;;AAkEA,wCA6GC;AA/KD,+CAAqE;AACrE,2DAA2F;AAW3F,MAAa,QAAS,SAAQ,KAAK;IAOjC,YACE,mBAAoD,IAAI,EACxD,gBAAgB,GAAG,GAAG,EACtB,aAAqB,wBAAU,CAAC,MAAM,CAAC,qBAAqB;QAE5D,IAAI,OAAwB,CAAC;QAE7B,IAAI,OAAO,gBAAgB,KAAK,QAAQ,IAAI,gBAAgB,KAAK,IAAI,EAAE,CAAC;YACtE,OAAO,GAAG,gBAAgB,CAAC;QAC7B,CAAC;aAAM,CAAC;YACN,OAAO,GAAG;gBACR,OAAO,EAAE,gBAAgB,IAAI,SAAS;gBACtC,UAAU,EAAE,gBAAgB;gBAC5B,IAAI,EAAE,UAAU;aACjB,CAAC;QACJ,CAAC;QAED,MAAM,EACJ,OAAO,EACP,IAAI,GAAG,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;QACnB,KAAK,iBAAiB;YACpB,OAAO,IAAI,QAAQ,CAAC;gBAClB,IAAI,EAAE,wBAAU,CAAC,IAAI,CAAC,SAAS;gBAC/B,UAAU,EAAE,GAAG;gBACf,OAAO,EAAE,iCAAiC;gBAC1C,KAAK,EAAE,KAAK;aACb,CAAC,CAAC;QAEL,KAAK,uBAAuB;YAC1B,OAAO,IAAI,QAAQ,CAAC;gBAClB,IAAI,EAAE,wBAAU,CAAC,IAAI,CAAC,cAAc;gBACpC,UAAU,EAAE,GAAG;gBACf,OAAO,EAAE,kCAAkC;gBAC3C,KAAK,EAAE,KAAK;aACb,CAAC,CAAC;QAEL;YACE,OAAO,IAAI,QAAQ,CAAC;gBAClB,IAAI,EAAE,wBAAU,CAAC,IAAI,CAAC,aAAa;gBACnC,UAAU,EAAE,GAAG;gBACf,OAAO,EAAE,iCAAiC;gBAC1C,KAAK,EAAE,KAAK;aACb,CAAC,CAAC;IACP,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-handler.d.ts","sourceRoot":"","sources":["../../src/errors/async-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE1E,wBAAgB,YAAY,CAC1B,OAAO,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,GACvF,cAAc,CAIhB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.asyncHandler = asyncHandler;
|
|
4
|
+
function asyncHandler(handler) {
|
|
5
|
+
return (req, res, next) => {
|
|
6
|
+
Promise.resolve(handler(req, res, next)).catch(next);
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=async-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-handler.js","sourceRoot":"","sources":["../../src/errors/async-handler.ts"],"names":[],"mappings":";;AAEA,oCAMC;AAND,SAAgB,YAAY,CAC1B,OAAwF;IAExF,OAAO,CAAC,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAQ,EAAE;QAC/D,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACvD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AxiosError } from
|
|
1
|
+
import { AxiosError } from 'axios';
|
|
2
2
|
export declare const parseAxiosError: (error: AxiosError) => {
|
|
3
3
|
success?: undefined;
|
|
4
4
|
error?: undefined;
|
|
@@ -8,3 +8,4 @@ export declare const parseAxiosError: (error: AxiosError) => {
|
|
|
8
8
|
error: any;
|
|
9
9
|
status: number;
|
|
10
10
|
};
|
|
11
|
+
//# sourceMappingURL=axios-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axios-error.d.ts","sourceRoot":"","sources":["../../src/errors/axios-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAGnC,eAAO,MAAM,eAAe,GAAI,OAAO,UAAU;;;;;;;;CA6BhD,CAAC"}
|
|
@@ -1,26 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseAxiosError = void 0;
|
|
4
|
+
const drapcode_logger_1 = require("drapcode-logger");
|
|
4
5
|
const parseAxiosError = (error) => {
|
|
5
6
|
if (!error) {
|
|
6
7
|
return {};
|
|
7
8
|
}
|
|
8
9
|
const { response, request, message } = error;
|
|
9
|
-
let errData =
|
|
10
|
+
let errData = '', errStatus = 400;
|
|
10
11
|
if (response) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
drapcode_logger_1.logger.error({
|
|
13
|
+
data: response.data,
|
|
14
|
+
status: response.status,
|
|
15
|
+
headers: response.headers,
|
|
16
|
+
}, `err.response:`);
|
|
14
17
|
errData = response.data;
|
|
15
18
|
errStatus = response.status;
|
|
16
19
|
}
|
|
17
20
|
else if (request) {
|
|
18
|
-
errData =
|
|
19
|
-
|
|
21
|
+
errData = 'No Response Received from the API';
|
|
22
|
+
drapcode_logger_1.logger.error(`err.request: ${JSON.stringify(request)}`);
|
|
20
23
|
}
|
|
21
24
|
else {
|
|
22
|
-
if (message.includes(
|
|
23
|
-
errData =
|
|
25
|
+
if (message.includes('ECONNABORTED')) {
|
|
26
|
+
errData = 'No response received from the REST API';
|
|
24
27
|
}
|
|
25
28
|
else {
|
|
26
29
|
errData = message;
|
|
@@ -29,3 +32,4 @@ const parseAxiosError = (error) => {
|
|
|
29
32
|
return { success: false, error: errData, status: errStatus };
|
|
30
33
|
};
|
|
31
34
|
exports.parseAxiosError = parseAxiosError;
|
|
35
|
+
//# sourceMappingURL=axios-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axios-error.js","sourceRoot":"","sources":["../../src/errors/axios-error.ts"],"names":[],"mappings":";;;AACA,qDAAyC;AAElC,MAAM,eAAe,GAAG,CAAC,KAAiB,EAAE,EAAE;IACnD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IAC7C,IAAI,OAAO,GAAQ,EAAE,EACnB,SAAS,GAAG,GAAG,CAAC;IAClB,IAAI,QAAQ,EAAE,CAAC;QACb,wBAAM,CAAC,KAAK,CACV;YACE,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,MAAM,EAAE,QAAQ,CAAC,MAAM;YACvB,OAAO,EAAE,QAAQ,CAAC,OAAO;SAC1B,EACD,eAAe,CAChB,CAAC;QACF,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC;QACxB,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC;IAC9B,CAAC;SAAM,IAAI,OAAO,EAAE,CAAC;QACnB,OAAO,GAAG,mCAAmC,CAAC;QAC9C,wBAAM,CAAC,KAAK,CAAC,gBAAgB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC1D,CAAC;SAAM,CAAC;QACN,IAAI,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;YACrC,OAAO,GAAG,wCAAwC,CAAC;QACrD,CAAC;aAAM,CAAC;YACN,OAAO,GAAG,OAAO,CAAC;QACpB,CAAC;IACH,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;AAC/D,CAAC,CAAC;AA7BW,QAAA,eAAe,mBA6B1B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CustomError } from
|
|
1
|
+
import { CustomError } from './custom-error';
|
|
2
2
|
export declare class BadRequestError extends CustomError {
|
|
3
3
|
message: string;
|
|
4
4
|
statusCode: number;
|
|
@@ -7,3 +7,4 @@ export declare class BadRequestError extends CustomError {
|
|
|
7
7
|
message: string;
|
|
8
8
|
}[];
|
|
9
9
|
}
|
|
10
|
+
//# sourceMappingURL=bad-request-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bad-request-error.d.ts","sourceRoot":"","sources":["../../src/errors/bad-request-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,qBAAa,eAAgB,SAAQ,WAAW;IAG3B,OAAO,EAAE,MAAM;IAFlC,UAAU,SAAO;gBAEE,OAAO,EAAE,MAAM;IAKlC,eAAe;;;CAGhB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bad-request-error.js","sourceRoot":"","sources":["../../src/errors/bad-request-error.ts"],"names":[],"mappings":";;;AAAA,iDAA6C;AAC7C,MAAa,eAAgB,SAAQ,0BAAW;IAG9C,YAAmB,OAAe;QAChC,KAAK,CAAC,OAAO,CAAC,CAAC;QADE,YAAO,GAAP,OAAO,CAAQ;QAFlC,eAAU,GAAG,GAAG,CAAC;QAIf,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;IACzD,CAAC;IAED,eAAe;QACb,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;IACrC,CAAC;CACF;AAXD,0CAWC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-error.d.ts","sourceRoot":"","sources":["../../src/errors/custom-error.ts"],"names":[],"mappings":"AAAA,8BAAsB,WAAY,SAAQ,KAAK;IAC7C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;gBAEhB,OAAO,EAAE,MAAM;IAK3B,QAAQ,CAAC,eAAe,IAAI;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE;CAClE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-error.js","sourceRoot":"","sources":["../../src/errors/custom-error.ts"],"names":[],"mappings":";;;AAAA,MAAsB,WAAY,SAAQ,KAAK;IAG7C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IACrD,CAAC;CAGF;AATD,kCASC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AppError } from './app-error';
|
|
2
|
+
export declare class ValidationError extends AppError {
|
|
3
|
+
constructor(message?: string, code?: string, details?: unknown);
|
|
4
|
+
}
|
|
5
|
+
export declare class BadRequestError extends AppError {
|
|
6
|
+
constructor(message?: string, code?: string, details?: unknown);
|
|
7
|
+
}
|
|
8
|
+
export declare class NotFoundError extends AppError {
|
|
9
|
+
constructor(message?: string, code?: string, details?: unknown);
|
|
10
|
+
}
|
|
11
|
+
export declare class UnauthorizedError extends AppError {
|
|
12
|
+
constructor(message?: string, code?: string, details?: unknown);
|
|
13
|
+
}
|
|
14
|
+
export declare class ForbiddenError extends AppError {
|
|
15
|
+
constructor(message?: string, code?: string, details?: unknown);
|
|
16
|
+
}
|
|
17
|
+
export declare class ConflictError extends AppError {
|
|
18
|
+
constructor(message?: string, code?: string, details?: unknown);
|
|
19
|
+
}
|
|
20
|
+
export declare class InternalServerError extends AppError {
|
|
21
|
+
constructor(message?: string, code?: string, details?: unknown);
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=error-classes.d.ts.map
|