Skip to content

Commit e0ed562

Browse files
committed
test cases passed
1 parent 596c6e1 commit e0ed562

File tree

6 files changed

+30
-35
lines changed

6 files changed

+30
-35
lines changed

libs/manage/cache.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ const getPurgeCacheStatus = function (
4545
var requestOptions = {
4646
url: "https://api.imagekit.io/v1/files/purge/" + requestId,
4747
method: "GET",
48-
json: true,
4948
};
5049

5150
request(requestOptions, defaultOptions, callback);

libs/manage/file.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ const deleteFile = function (fileId: string, defaultOptions: ImageKitOptions, ca
3737

3838
var requestOptions = {
3939
url: "https://api.imagekit.io/v1/files/" + fileId,
40-
method: "DELETE",
41-
json: true,
40+
method: "DELETE"
4241
};
4342

4443
request(requestOptions, defaultOptions, callback);
@@ -59,16 +58,14 @@ const getMetadata = function (
5958

6059
var requestOptions = {
6160
url: "https://api.imagekit.io/v1/files/" + fileIdOrURL + "/metadata",
62-
method: "GET",
63-
json: true,
61+
method: "GET"
6462
};
6563

6664
// In case of URL change the endopint
6765
if (fileIdOrURL.indexOf("http") === 0) {
6866
requestOptions = {
6967
url: `https://api.imagekit.io/v1/metadata?url=${fileIdOrURL}`,
70-
method: "GET",
71-
json: true,
68+
method: "GET"
7269
};
7370
}
7471

@@ -90,8 +87,7 @@ const getDetails = function (
9087

9188
var requestOptions = {
9289
url: "https://api.imagekit.io/v1/files/" + fileId + "/details",
93-
method: "GET",
94-
json: true,
90+
method: "GET"
9591
};
9692

9793
request(requestOptions, defaultOptions, callback);
@@ -147,8 +143,7 @@ const listFiles = function (
147143
var requestOptions = {
148144
url: `https://api.imagekit.io/v1/files/`,
149145
method: "GET",
150-
qs: listOptions || {},
151-
json: true,
146+
qs: listOptions || {}
152147
};
153148

154149
request(requestOptions, defaultOptions, callback);
@@ -456,8 +451,7 @@ const getBulkJobStatus = function (jobId: string, defaultOptions: ImageKitOption
456451

457452
const requestOptions = {
458453
url: "https://api.imagekit.io/v1/bulkJobs/" + jobId,
459-
method: "GET",
460-
json: true,
454+
method: "GET"
461455
};
462456

463457
request(requestOptions, defaultOptions, callback);

libs/upload/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ export default function (
9797
var requestOptions = {
9898
url: defaultOptions.uploadEndpoint || "https://upload.imagekit.io/api/v1/files/upload",
9999
method: "POST",
100-
formData: form,
101-
json: true,
100+
formData: form
102101
};
103102

104103
request(requestOptions, defaultOptions, callback);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"chai": "^4.2.0",
3939
"codecov": "^3.8.0",
4040
"mocha": "^8.1.1",
41-
"nock": "^13.0.4",
41+
"nock": "^13.2.7",
4242
"nyc": "^15.1.0",
4343
"sinon": "^9.2.0",
4444
"typescript": "^4.3.2"

utils/request.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,15 @@ export default function (
5050
respond(true, error.response.data, callback);
5151
}
5252

53-
} else if (error.request) {
53+
} else if (error) {
54+
respond(true, error, callback);
5455
// The request was made but no response was received
5556
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
5657
// http.ClientRequest in node.js
57-
respond(true, error.request, callback);
5858
} else {
59-
// Something happened in setting up the request that triggered an Error
60-
respond(true, error.message, callback);
59+
respond(true, {
60+
message: "Unknown error occured"
61+
}, callback);
6162
}
6263
})
6364

yarn.lock

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,7 +1569,7 @@ cross-spawn@^7.0.0:
15691569
shebang-command "^2.0.0"
15701570
which "^2.0.1"
15711571

1572-
debug@4, debug@^4.1.0, debug@^4.1.1:
1572+
debug@4, debug@^4.1.1:
15731573
version "4.3.2"
15741574
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.2.tgz#f0a49c18ac8779e31d4a0c6029dfb76873c7428b"
15751575
integrity sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==
@@ -1590,6 +1590,13 @@ debug@^2.2.0, debug@^2.3.3:
15901590
dependencies:
15911591
ms "2.0.0"
15921592

1593+
debug@^4.1.0:
1594+
version "4.3.4"
1595+
resolved "https://npm.imagekit.io/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865"
1596+
integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==
1597+
dependencies:
1598+
ms "2.1.2"
1599+
15931600
decamelize@^1.2.0:
15941601
version "1.2.0"
15951602
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290"
@@ -2439,7 +2446,7 @@ jsesc@~0.5.0:
24392446

24402447
json-stringify-safe@^5.0.1:
24412448
version "5.0.1"
2442-
resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb"
2449+
resolved "https://npm.imagekit.io/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb"
24432450
integrity sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=
24442451

24452452
json5@^2.1.2:
@@ -2515,12 +2522,7 @@ lodash.get@^4.4.2:
25152522
resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99"
25162523
integrity sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=
25172524

2518-
lodash.set@^4.3.2:
2519-
version "4.3.2"
2520-
resolved "https://registry.yarnpkg.com/lodash.set/-/lodash.set-4.3.2.tgz#d8757b1da807dde24816b0d6a84bea1a76230b23"
2521-
integrity sha1-2HV7HagH3eJIFrDWqEvqGnYjCyM=
2522-
2523-
lodash@^4.17.15:
2525+
lodash@^4.17.15, lodash@^4.17.21:
25242526
version "4.17.21"
25252527
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
25262528
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
@@ -2648,7 +2650,7 @@ [email protected]:
26482650

26492651
26502652
version "2.1.2"
2651-
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009"
2653+
resolved "https://npm.imagekit.io/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009"
26522654
integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==
26532655

26542656
@@ -2689,14 +2691,14 @@ nise@^4.0.4:
26892691
just-extend "^4.0.2"
26902692
path-to-regexp "^1.7.0"
26912693

2692-
nock@^13.0.4:
2693-
version "13.1.1"
2694-
resolved "https://registry.yarnpkg.com/nock/-/nock-13.1.1.tgz#3c830129d4560957f59b6f480a41ddbaf9cf57af"
2695-
integrity sha512-YKTR9MjfK3kS9/l4nuTxyYm30cgOExRHzkLNhL8nhEUyU4f8Za/dRxOqjhVT1vGs0svWo3dDnJTUX1qxYeWy5w==
2694+
nock@^13.2.7:
2695+
version "13.2.7"
2696+
resolved "https://npm.imagekit.io/nock/-/nock-13.2.7.tgz#c93933b61df42f4f4b3a07fde946a4e209c0c168"
2697+
integrity sha512-R6NUw7RIPtKwgK7jskuKoEi4VFMqIHtV2Uu9K/Uegc4TA5cqe+oNMYslZcUmnVNQCTG6wcSqUBaGTDd7sq5srg==
26962698
dependencies:
26972699
debug "^4.1.0"
26982700
json-stringify-safe "^5.0.1"
2699-
lodash.set "^4.3.2"
2701+
lodash "^4.17.21"
27002702
propagate "^2.0.0"
27012703

27022704
node-environment-flags@^1.0.5:
@@ -2987,7 +2989,7 @@ process-on-spawn@^1.0.0:
29872989

29882990
propagate@^2.0.0:
29892991
version "2.0.1"
2990-
resolved "https://registry.yarnpkg.com/propagate/-/propagate-2.0.1.tgz#40cdedab18085c792334e64f0ac17256d38f9a45"
2992+
resolved "https://npm.imagekit.io/propagate/-/propagate-2.0.1.tgz#40cdedab18085c792334e64f0ac17256d38f9a45"
29912993
integrity sha512-vGrhOavPSTz4QVNuBNdcNXePNdNMaO1xj9yBeH1ScQPjk/rhg9sSlCXPhMkFuaNNW/syTvYqsnbIJxMBfRbbag==
29922994

29932995
randombytes@^2.1.0:

0 commit comments

Comments
 (0)