Skip to content

Commit 7422da4

Browse files
committed
upload endpoint fix
1 parent dd89e0c commit 7422da4

File tree

5 files changed

+14
-12
lines changed

5 files changed

+14
-12
lines changed

index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ const promisify = function <T = void>(thisContext: ImageKit, fn: Function) {
6262

6363
class ImageKit {
6464
options: ImageKitOptions = {
65+
uploadEndpoint: "https://upload.imagekit.io/api/v1/files/upload",
6566
publicKey: "",
6667
privateKey: "",
6768
urlEndpoint: "",

libs/interfaces/ImageKitOptions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { TransformationPosition } from ".";
22

33
export interface ImageKitOptions {
4+
uploadEndpoint?: string,
45
publicKey: string;
56
privateKey: string;
67
urlEndpoint: string;

libs/upload/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export default function (
5757
}
5858

5959
var requestOptions = {
60-
url: "https://api.imagekit.io/v1/files/upload",
60+
url: defaultOptions.uploadEndpoint || "https://upload.imagekit.io/api/v1/files/upload",
6161
method: "POST",
6262
formData: formData,
6363
json: true,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "imagekit",
3-
"version": "3.2.1",
3+
"version": "3.2.2",
44
"description": "Offical NodeJS SDK for ImageKit.io integration",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

tests/upload.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ describe("File upload", function () {
7373

7474
var callback = sinon.spy();
7575

76-
const scope = nock('https://api.imagekit.io')
76+
const scope = nock('https://upload.imagekit.io/api')
7777
.post('/v1/files/upload')
7878
.basicAuth({ user: initializationParams.privateKey, pass: '' })
7979
.reply(200, function (uri, requestBody) {
@@ -97,7 +97,7 @@ describe("File upload", function () {
9797
file: fs.readFileSync(path.join(__dirname,"./data/test_image.jpg"))
9898
};
9999

100-
const scope = nock('https://api.imagekit.io')
100+
const scope = nock('https://upload.imagekit.io/api')
101101
.post('/v1/files/upload')
102102
.basicAuth({ user: initializationParams.privateKey, pass: '' })
103103
.reply(200, function (uri, requestBody) {
@@ -119,7 +119,7 @@ describe("File upload", function () {
119119

120120
var callback = sinon.spy();
121121

122-
const scope = nock('https://api.imagekit.io')
122+
const scope = nock('https://upload.imagekit.io/api')
123123
.post('/v1/files/upload')
124124
.basicAuth({ user: initializationParams.privateKey, pass: '' })
125125
.reply(200, function (uri, requestBody) {
@@ -144,7 +144,7 @@ describe("File upload", function () {
144144

145145
var callback = sinon.spy();
146146

147-
const scope = nock('https://api.imagekit.io')
147+
const scope = nock('https://upload.imagekit.io/api')
148148
.post('/v1/files/upload')
149149
.basicAuth({ user: initializationParams.privateKey, pass: '' })
150150
.reply(200, function (uri, requestBody) {
@@ -169,7 +169,7 @@ describe("File upload", function () {
169169

170170
var callback = sinon.spy();
171171

172-
const scope = nock('https://api.imagekit.io')
172+
const scope = nock('https://upload.imagekit.io/api')
173173
.post('/v1/files/upload')
174174
.basicAuth({ user: initializationParams.privateKey, pass: '' })
175175
.reply(200, function (uri, requestBody) {
@@ -196,7 +196,7 @@ describe("File upload", function () {
196196

197197
var callback = sinon.spy();
198198

199-
const scope = nock('https://api.imagekit.io')
199+
const scope = nock('https://upload.imagekit.io/api')
200200
.post('/v1/files/upload')
201201
.basicAuth({ user: initializationParams.privateKey, pass: '' })
202202
.reply(200, uploadSuccessResponseObj)
@@ -216,7 +216,7 @@ describe("File upload", function () {
216216
file: "test_file_content"
217217
};
218218

219-
const scope = nock('https://api.imagekit.io')
219+
const scope = nock('https://upload.imagekit.io/api')
220220
.post('/v1/files/upload')
221221
.basicAuth({ user: initializationParams.privateKey, pass: '' })
222222
.reply(200, uploadSuccessResponseObj)
@@ -234,7 +234,7 @@ describe("File upload", function () {
234234
file: "test_file_content"
235235
};
236236

237-
const scope = nock('https://api.imagekit.io')
237+
const scope = nock('https://upload.imagekit.io/api')
238238
.post('/v1/files/upload')
239239
.basicAuth({ user: initializationParams.privateKey, pass: '' })
240240
.replyWithError("Network error occured")
@@ -258,7 +258,7 @@ describe("File upload", function () {
258258
message: "Your account cannot be authenticated."
259259
};
260260

261-
const scope = nock('https://api.imagekit.io')
261+
const scope = nock('https://upload.imagekit.io/api')
262262
.post('/v1/files/upload')
263263
.basicAuth({ user: initializationParams.privateKey, pass: '' })
264264
.reply(403, error)
@@ -283,7 +283,7 @@ describe("File upload", function () {
283283
message: "Your account cannot be authenticated."
284284
};
285285

286-
const scope = nock('https://api.imagekit.io')
286+
const scope = nock('https://upload.imagekit.io/api')
287287
.post('/v1/files/upload')
288288
.basicAuth({ user: initializationParams.privateKey, pass: '' })
289289
.reply(403, error)

0 commit comments

Comments
 (0)