diginext-utils 3.11.3 → 3.11.4
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/README.md +162 -162
- package/dist/images/loadImageAsBlobUrl.d.ts +1 -1
- package/dist/images/loadImageAsBlobUrl.js +4 -3
- package/dist/images/loadImageAsBlobUrl.js.map +1 -1
- package/dist/response/index.js +2 -2
- package/dist/response/index.js.map +1 -1
- package/esm/images/loadImageAsBlobUrl.d.ts +1 -1
- package/esm/images/loadImageAsBlobUrl.js +4 -3
- package/esm/images/loadImageAsBlobUrl.js.map +1 -1
- package/esm/response/index.js +2 -2
- package/esm/response/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,162 +1,162 @@
|
|
|
1
|
-
# The library of utility plugins
|
|
2
|
-
|
|
3
|
-
## Exports
|
|
4
|
-
|
|
5
|
-
- "diginext-utils/dist": ES6 modules / NodeJS
|
|
6
|
-
- "diginext-utils/esm": Node modules / JavaScript modules
|
|
7
|
-
|
|
8
|
-
## Imports
|
|
9
|
-
|
|
10
|
-
### ES5 module import:
|
|
11
|
-
|
|
12
|
-
```javascript
|
|
13
|
-
import utils from "diginext-utils";
|
|
14
|
-
console.log(utils.xname.NameEN.generateName()); // output some random name in English
|
|
15
|
-
|
|
16
|
-
// or
|
|
17
|
-
|
|
18
|
-
import { NameEN } from "diginext-utils/dist/name";
|
|
19
|
-
console.log(NameEN.generateName()); // output some random name in English
|
|
20
|
-
|
|
21
|
-
// or just
|
|
22
|
-
import { generateName } from "diginext-utils/dist/name/en";
|
|
23
|
-
console.log(generateName()); // output some random name in English
|
|
24
|
-
|
|
25
|
-
// or with require(...)
|
|
26
|
-
const xurl = require("../dist/string/url");
|
|
27
|
-
xurl.isLink("abc"); // FALSE
|
|
28
|
-
xurl.isLink("https://www.google.com"); // TRUE
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
### Node module import:
|
|
32
|
-
|
|
33
|
-
**IMPORTANT**: Set "type" as "module" your `package.json`
|
|
34
|
-
|
|
35
|
-
```javascript
|
|
36
|
-
// NodeJS moduies
|
|
37
|
-
import utils from "diginext-utils";
|
|
38
|
-
console.log(utils.xname.NameEN.generateName()); // output some random name in English
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
```html
|
|
42
|
-
// browser
|
|
43
|
-
<script type="module">
|
|
44
|
-
import { NameEN } from "diginext-utils/esm/name/index.js"; // ".js" file extension is required !
|
|
45
|
-
console.log(NameEN.generateName()); // output some random name in English
|
|
46
|
-
</script>
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
## Features
|
|
50
|
-
|
|
51
|
-
- xconsole
|
|
52
|
-
- xarray
|
|
53
|
-
- sumArray
|
|
54
|
-
- averageArray
|
|
55
|
-
- minArray
|
|
56
|
-
- maxArray
|
|
57
|
-
- sortElementByString
|
|
58
|
-
- sortElementByNumber
|
|
59
|
-
- firstElement
|
|
60
|
-
- lastElement
|
|
61
|
-
- randomIndex
|
|
62
|
-
- randomElement
|
|
63
|
-
- mergeAndMakeUniqueElement
|
|
64
|
-
- allMatchInArray
|
|
65
|
-
- removeItem
|
|
66
|
-
- removeItemByKey
|
|
67
|
-
- getRandom
|
|
68
|
-
- getHalfRandom
|
|
69
|
-
- shuffle
|
|
70
|
-
- moveIndex
|
|
71
|
-
- moveArray
|
|
72
|
-
- xmath
|
|
73
|
-
- rand
|
|
74
|
-
- randRound
|
|
75
|
-
- randHalt
|
|
76
|
-
- randInt
|
|
77
|
-
- randFloat
|
|
78
|
-
- degToRad
|
|
79
|
-
- radToDeg
|
|
80
|
-
- angleBetweenPoints
|
|
81
|
-
- diffDate
|
|
82
|
-
- positiveNumber
|
|
83
|
-
- xname
|
|
84
|
-
- NameEN.generateName()
|
|
85
|
-
- NameVI.generateName()
|
|
86
|
-
- xobject
|
|
87
|
-
- isNull
|
|
88
|
-
- toBool
|
|
89
|
-
- toInt
|
|
90
|
-
- toFloat
|
|
91
|
-
- toArray
|
|
92
|
-
- objectToArray
|
|
93
|
-
- xjson
|
|
94
|
-
- isValid
|
|
95
|
-
- xfile
|
|
96
|
-
- createDir
|
|
97
|
-
- fileMove
|
|
98
|
-
- findFileByExt
|
|
99
|
-
- xstring
|
|
100
|
-
- getBetween
|
|
101
|
-
- makeString
|
|
102
|
-
- toUpperCase
|
|
103
|
-
- toLowerCase
|
|
104
|
-
- titleize
|
|
105
|
-
- capitalize
|
|
106
|
-
- capitalizeName
|
|
107
|
-
- clearUnicodeCharacters
|
|
108
|
-
- generateUUID
|
|
109
|
-
- randAllCharacterByLength
|
|
110
|
-
- randomStringByLength
|
|
111
|
-
- formatNumber
|
|
112
|
-
- generatePassword
|
|
113
|
-
- trimNull
|
|
114
|
-
- addQueryParam
|
|
115
|
-
- getUrlParams
|
|
116
|
-
- isLink
|
|
117
|
-
- getFileNameWithoutExtension
|
|
118
|
-
- getFileNameWithExtension
|
|
119
|
-
- getFileExtension
|
|
120
|
-
- isImage
|
|
121
|
-
- xurl
|
|
122
|
-
- addQueryParam
|
|
123
|
-
- getUrlParams
|
|
124
|
-
- isLink
|
|
125
|
-
- getFileNameWithoutExtension
|
|
126
|
-
- getFileNameWithExtension
|
|
127
|
-
- getFileExtension
|
|
128
|
-
- isImage
|
|
129
|
-
- slug
|
|
130
|
-
- makeSlug
|
|
131
|
-
- color
|
|
132
|
-
- random
|
|
133
|
-
- pSBC
|
|
134
|
-
- hexToRgb
|
|
135
|
-
- hexDarken
|
|
136
|
-
- hexLighten
|
|
137
|
-
- RGBToHex
|
|
138
|
-
- device
|
|
139
|
-
- camera
|
|
140
|
-
- requestCamera
|
|
141
|
-
- requestDeviceOrientationControl
|
|
142
|
-
- browser
|
|
143
|
-
- isPotrait
|
|
144
|
-
- isLandscape
|
|
145
|
-
- ua
|
|
146
|
-
- isFacebookWebview
|
|
147
|
-
- isInAppWebview
|
|
148
|
-
- Timer
|
|
149
|
-
- wait
|
|
150
|
-
- Validation
|
|
151
|
-
- imageValidate
|
|
152
|
-
- videoValidate
|
|
153
|
-
|
|
154
|
-
## Dev
|
|
155
|
-
|
|
156
|
-
```
|
|
157
|
-
yarn dev
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
## Support
|
|
161
|
-
|
|
162
|
-
Liên hệ [TOP GROUP Developers](mailto:dev@wearetopgroup.com) nếu cần hỗ trợ.
|
|
1
|
+
# The library of utility plugins
|
|
2
|
+
|
|
3
|
+
## Exports
|
|
4
|
+
|
|
5
|
+
- "diginext-utils/dist": ES6 modules / NodeJS
|
|
6
|
+
- "diginext-utils/esm": Node modules / JavaScript modules
|
|
7
|
+
|
|
8
|
+
## Imports
|
|
9
|
+
|
|
10
|
+
### ES5 module import:
|
|
11
|
+
|
|
12
|
+
```javascript
|
|
13
|
+
import utils from "diginext-utils";
|
|
14
|
+
console.log(utils.xname.NameEN.generateName()); // output some random name in English
|
|
15
|
+
|
|
16
|
+
// or
|
|
17
|
+
|
|
18
|
+
import { NameEN } from "diginext-utils/dist/name";
|
|
19
|
+
console.log(NameEN.generateName()); // output some random name in English
|
|
20
|
+
|
|
21
|
+
// or just
|
|
22
|
+
import { generateName } from "diginext-utils/dist/name/en";
|
|
23
|
+
console.log(generateName()); // output some random name in English
|
|
24
|
+
|
|
25
|
+
// or with require(...)
|
|
26
|
+
const xurl = require("../dist/string/url");
|
|
27
|
+
xurl.isLink("abc"); // FALSE
|
|
28
|
+
xurl.isLink("https://www.google.com"); // TRUE
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Node module import:
|
|
32
|
+
|
|
33
|
+
**IMPORTANT**: Set "type" as "module" your `package.json`
|
|
34
|
+
|
|
35
|
+
```javascript
|
|
36
|
+
// NodeJS moduies
|
|
37
|
+
import utils from "diginext-utils";
|
|
38
|
+
console.log(utils.xname.NameEN.generateName()); // output some random name in English
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
```html
|
|
42
|
+
// browser
|
|
43
|
+
<script type="module">
|
|
44
|
+
import { NameEN } from "diginext-utils/esm/name/index.js"; // ".js" file extension is required !
|
|
45
|
+
console.log(NameEN.generateName()); // output some random name in English
|
|
46
|
+
</script>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Features
|
|
50
|
+
|
|
51
|
+
- xconsole
|
|
52
|
+
- xarray
|
|
53
|
+
- sumArray
|
|
54
|
+
- averageArray
|
|
55
|
+
- minArray
|
|
56
|
+
- maxArray
|
|
57
|
+
- sortElementByString
|
|
58
|
+
- sortElementByNumber
|
|
59
|
+
- firstElement
|
|
60
|
+
- lastElement
|
|
61
|
+
- randomIndex
|
|
62
|
+
- randomElement
|
|
63
|
+
- mergeAndMakeUniqueElement
|
|
64
|
+
- allMatchInArray
|
|
65
|
+
- removeItem
|
|
66
|
+
- removeItemByKey
|
|
67
|
+
- getRandom
|
|
68
|
+
- getHalfRandom
|
|
69
|
+
- shuffle
|
|
70
|
+
- moveIndex
|
|
71
|
+
- moveArray
|
|
72
|
+
- xmath
|
|
73
|
+
- rand
|
|
74
|
+
- randRound
|
|
75
|
+
- randHalt
|
|
76
|
+
- randInt
|
|
77
|
+
- randFloat
|
|
78
|
+
- degToRad
|
|
79
|
+
- radToDeg
|
|
80
|
+
- angleBetweenPoints
|
|
81
|
+
- diffDate
|
|
82
|
+
- positiveNumber
|
|
83
|
+
- xname
|
|
84
|
+
- NameEN.generateName()
|
|
85
|
+
- NameVI.generateName()
|
|
86
|
+
- xobject
|
|
87
|
+
- isNull
|
|
88
|
+
- toBool
|
|
89
|
+
- toInt
|
|
90
|
+
- toFloat
|
|
91
|
+
- toArray
|
|
92
|
+
- objectToArray
|
|
93
|
+
- xjson
|
|
94
|
+
- isValid
|
|
95
|
+
- xfile
|
|
96
|
+
- createDir
|
|
97
|
+
- fileMove
|
|
98
|
+
- findFileByExt
|
|
99
|
+
- xstring
|
|
100
|
+
- getBetween
|
|
101
|
+
- makeString
|
|
102
|
+
- toUpperCase
|
|
103
|
+
- toLowerCase
|
|
104
|
+
- titleize
|
|
105
|
+
- capitalize
|
|
106
|
+
- capitalizeName
|
|
107
|
+
- clearUnicodeCharacters
|
|
108
|
+
- generateUUID
|
|
109
|
+
- randAllCharacterByLength
|
|
110
|
+
- randomStringByLength
|
|
111
|
+
- formatNumber
|
|
112
|
+
- generatePassword
|
|
113
|
+
- trimNull
|
|
114
|
+
- addQueryParam
|
|
115
|
+
- getUrlParams
|
|
116
|
+
- isLink
|
|
117
|
+
- getFileNameWithoutExtension
|
|
118
|
+
- getFileNameWithExtension
|
|
119
|
+
- getFileExtension
|
|
120
|
+
- isImage
|
|
121
|
+
- xurl
|
|
122
|
+
- addQueryParam
|
|
123
|
+
- getUrlParams
|
|
124
|
+
- isLink
|
|
125
|
+
- getFileNameWithoutExtension
|
|
126
|
+
- getFileNameWithExtension
|
|
127
|
+
- getFileExtension
|
|
128
|
+
- isImage
|
|
129
|
+
- slug
|
|
130
|
+
- makeSlug
|
|
131
|
+
- color
|
|
132
|
+
- random
|
|
133
|
+
- pSBC
|
|
134
|
+
- hexToRgb
|
|
135
|
+
- hexDarken
|
|
136
|
+
- hexLighten
|
|
137
|
+
- RGBToHex
|
|
138
|
+
- device
|
|
139
|
+
- camera
|
|
140
|
+
- requestCamera
|
|
141
|
+
- requestDeviceOrientationControl
|
|
142
|
+
- browser
|
|
143
|
+
- isPotrait
|
|
144
|
+
- isLandscape
|
|
145
|
+
- ua
|
|
146
|
+
- isFacebookWebview
|
|
147
|
+
- isInAppWebview
|
|
148
|
+
- Timer
|
|
149
|
+
- wait
|
|
150
|
+
- Validation
|
|
151
|
+
- imageValidate
|
|
152
|
+
- videoValidate
|
|
153
|
+
|
|
154
|
+
## Dev
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
yarn dev
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Support
|
|
161
|
+
|
|
162
|
+
Liên hệ [TOP GROUP Developers](mailto:dev@wearetopgroup.com) nếu cần hỗ trợ.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function loadImageAsBlobUrl(imageUrl: string): Promise<string>;
|
|
1
|
+
export default function loadImageAsBlobUrl(imageUrl: string): Promise<string | null>;
|
|
@@ -7,7 +7,8 @@ const getUrlBypassCors_1 = __importDefault(require("./getUrlBypassCors"));
|
|
|
7
7
|
const tryLoad = async (url) => {
|
|
8
8
|
const response = await fetch(url);
|
|
9
9
|
if (!response.ok) {
|
|
10
|
-
|
|
10
|
+
return null;
|
|
11
|
+
// throw new Error(`HTTP error! status: ${response.status}`);
|
|
11
12
|
}
|
|
12
13
|
const imageBlob = await response.blob();
|
|
13
14
|
const blobUrl = URL.createObjectURL(imageBlob);
|
|
@@ -19,7 +20,7 @@ async function loadImageAsBlobUrl(imageUrl) {
|
|
|
19
20
|
return imageBlob;
|
|
20
21
|
}
|
|
21
22
|
catch (e) {
|
|
22
|
-
console.error(`loadImageAsBlobUrl error`, e);
|
|
23
|
+
// console.error(`loadImageAsBlobUrl error`, e);
|
|
23
24
|
}
|
|
24
25
|
try {
|
|
25
26
|
const url = (0, getUrlBypassCors_1.default)(imageUrl);
|
|
@@ -29,7 +30,7 @@ async function loadImageAsBlobUrl(imageUrl) {
|
|
|
29
30
|
return imageBlob;
|
|
30
31
|
}
|
|
31
32
|
catch (error) {
|
|
32
|
-
console.error(`loadImageAsBlobUrl error`, error);
|
|
33
|
+
// console.error(`loadImageAsBlobUrl error`, error);
|
|
33
34
|
}
|
|
34
35
|
return imageUrl;
|
|
35
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadImageAsBlobUrl.js","sourceRoot":"","sources":["../../src/images/loadImageAsBlobUrl.ts"],"names":[],"mappings":";;;;;AAAA,0EAAkD;AAElD,MAAM,OAAO,GAAG,KAAK,EAAE,GAAW,EAAE,EAAE;IACrC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE;QACjB,
|
|
1
|
+
{"version":3,"file":"loadImageAsBlobUrl.js","sourceRoot":"","sources":["../../src/images/loadImageAsBlobUrl.ts"],"names":[],"mappings":";;;;;AAAA,0EAAkD;AAElD,MAAM,OAAO,GAAG,KAAK,EAAE,GAAW,EAAE,EAAE;IACrC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE;QACjB,OAAO,IAAI,CAAA;QACX,6DAA6D;KAC7D;IAED,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IAExC,MAAM,OAAO,GAAG,GAAG,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;IAC/C,OAAO,OAAO,CAAC;AAChB,CAAC,CAAC;AAEa,KAAK,UAAU,kBAAkB,CAAC,QAAgB;IAChE,IAAI;QACH,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC1C,OAAO,SAAS,CAAC;KACjB;IAAC,OAAO,CAAC,EAAE;QACX,gDAAgD;KAChD;IAED,IAAI;QACH,MAAM,GAAG,GAAG,IAAA,0BAAgB,EAAC,QAAQ,CAAC,CAAC;QACvC,IAAI,CAAC,GAAG;YAAE,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAC5C,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC;QACrC,OAAO,SAAS,CAAC;KAEjB;IAAC,OAAO,KAAK,EAAE;QACf,oDAAoD;KACpD;IAED,OAAO,QAAQ,CAAA;AAChB,CAAC;AAnBD,qCAmBC"}
|
package/dist/response/index.js
CHANGED
|
@@ -25,7 +25,7 @@ const getFailedResponse = (...messages) => {
|
|
|
25
25
|
}, [])) || [];
|
|
26
26
|
// Provide a default message if none is provided
|
|
27
27
|
if (flattenedMessages.length === 0) {
|
|
28
|
-
flattenedMessages.push("
|
|
28
|
+
flattenedMessages.push("Something went wrong !");
|
|
29
29
|
}
|
|
30
30
|
// Return the response object
|
|
31
31
|
return { status: 0, error: true, messages: flattenedMessages, data: null };
|
|
@@ -56,7 +56,7 @@ exports.Response = {
|
|
|
56
56
|
return res.status(403).json((0, exports.getFailedResponse)(msg));
|
|
57
57
|
},
|
|
58
58
|
ignore: (res, message) => {
|
|
59
|
-
const msg = message ? message : "
|
|
59
|
+
const msg = message ? message : "Something went wrong?";
|
|
60
60
|
if (res.locals.logEnabled)
|
|
61
61
|
(0, log_1.logRes)(res, { statusCode: 404, message: msg });
|
|
62
62
|
return res.status(200).json((0, exports.getFailedResponse)(msg));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/response/index.ts"],"names":[],"mappings":";;;AAAA,yCAAyC;AAElC,MAAM,WAAW,GAAG,GAAG,EAAE;IAC/B,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AAChD,CAAC,CAAC;AAFW,QAAA,WAAW,eAEtB;AAEK,MAAM,kBAAkB,GAAG,CAAC,IAAS,EAAE,OAAgB,EAAE,EAAE;IACjE,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,IAAI,IAAI,EAAE,CAAC;AAC9E,CAAC,CAAC;AAFW,QAAA,kBAAkB,sBAE7B;AAEK,MAAM,iBAAiB,GAAG,CAAC,GAAG,QAA2C,EAAE,EAAE;;IACnF,mDAAmD;IACnD,MAAM,iBAAiB,GACtB,CAAA,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,MAAM,yDAAa,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE;QAC7C,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YAC3B,OAAO,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;SAC3B;aAAM,IAAI,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>;
|
|
@@ -2,7 +2,8 @@ import getUrlBypassCors from "./getUrlBypassCors";
|
|
|
2
2
|
const tryLoad = async (url) => {
|
|
3
3
|
const response = await fetch(url);
|
|
4
4
|
if (!response.ok) {
|
|
5
|
-
|
|
5
|
+
return null;
|
|
6
|
+
// throw new Error(`HTTP error! status: ${response.status}`);
|
|
6
7
|
}
|
|
7
8
|
const imageBlob = await response.blob();
|
|
8
9
|
const blobUrl = URL.createObjectURL(imageBlob);
|
|
@@ -14,7 +15,7 @@ export default async function loadImageAsBlobUrl(imageUrl) {
|
|
|
14
15
|
return imageBlob;
|
|
15
16
|
}
|
|
16
17
|
catch (e) {
|
|
17
|
-
console.error(`loadImageAsBlobUrl error`, e);
|
|
18
|
+
// console.error(`loadImageAsBlobUrl error`, e);
|
|
18
19
|
}
|
|
19
20
|
try {
|
|
20
21
|
const url = getUrlBypassCors(imageUrl);
|
|
@@ -24,7 +25,7 @@ export default async function loadImageAsBlobUrl(imageUrl) {
|
|
|
24
25
|
return imageBlob;
|
|
25
26
|
}
|
|
26
27
|
catch (error) {
|
|
27
|
-
console.error(`loadImageAsBlobUrl error`, error);
|
|
28
|
+
// console.error(`loadImageAsBlobUrl error`, error);
|
|
28
29
|
}
|
|
29
30
|
return imageUrl;
|
|
30
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadImageAsBlobUrl.js","sourceRoot":"","sources":["../../src/images/loadImageAsBlobUrl.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAElD,MAAM,OAAO,GAAG,KAAK,EAAE,GAAW,EAAE,EAAE;IACrC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE;QACjB,
|
|
1
|
+
{"version":3,"file":"loadImageAsBlobUrl.js","sourceRoot":"","sources":["../../src/images/loadImageAsBlobUrl.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAElD,MAAM,OAAO,GAAG,KAAK,EAAE,GAAW,EAAE,EAAE;IACrC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE;QACjB,OAAO,IAAI,CAAA;QACX,6DAA6D;KAC7D;IAED,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IAExC,MAAM,OAAO,GAAG,GAAG,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;IAC/C,OAAO,OAAO,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,kBAAkB,CAAC,QAAgB;IAChE,IAAI;QACH,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC1C,OAAO,SAAS,CAAC;KACjB;IAAC,OAAO,CAAC,EAAE;QACX,gDAAgD;KAChD;IAED,IAAI;QACH,MAAM,GAAG,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QACvC,IAAI,CAAC,GAAG;YAAE,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAC5C,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC;QACrC,OAAO,SAAS,CAAC;KAEjB;IAAC,OAAO,KAAK,EAAE;QACf,oDAAoD;KACpD;IAED,OAAO,QAAQ,CAAA;AAChB,CAAC"}
|
package/esm/response/index.js
CHANGED
|
@@ -20,7 +20,7 @@ export const getFailedResponse = (...messages) => {
|
|
|
20
20
|
}, [])) || [];
|
|
21
21
|
// Provide a default message if none is provided
|
|
22
22
|
if (flattenedMessages.length === 0) {
|
|
23
|
-
flattenedMessages.push("
|
|
23
|
+
flattenedMessages.push("Something went wrong !");
|
|
24
24
|
}
|
|
25
25
|
// Return the response object
|
|
26
26
|
return { status: 0, error: true, messages: flattenedMessages, data: null };
|
|
@@ -50,7 +50,7 @@ export const Response = {
|
|
|
50
50
|
return res.status(403).json(getFailedResponse(msg));
|
|
51
51
|
},
|
|
52
52
|
ignore: (res, message) => {
|
|
53
|
-
const msg = message ? message : "
|
|
53
|
+
const msg = message ? message : "Something went wrong?";
|
|
54
54
|
if (res.locals.logEnabled)
|
|
55
55
|
logRes(res, { statusCode: 404, message: msg });
|
|
56
56
|
return res.status(200).json(getFailedResponse(msg));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/response/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,EAAE;IAC/B,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AAChD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,IAAS,EAAE,OAAgB,EAAE,EAAE;IACjE,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,IAAI,IAAI,EAAE,CAAC;AAC9E,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,GAAG,QAA2C,EAAE,EAAE;;IACnF,mDAAmD;IACnD,MAAM,iBAAiB,GACtB,CAAA,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,MAAM,yDAAa,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE;QAC7C,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YAC3B,OAAO,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;SAC3B;aAAM,IAAI,CAAC,CAAC,OAAO,EAAE;YACrB,GAAG,CAAC,IAA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