Skip to content

Commit 712debd

Browse files
Merge pull request #108 from appwrite/dev
fix: remove content-type from GET requests
2 parents f75abab + 91783da commit 712debd

20 files changed

+40
-174
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Appwrite Node.js SDK
22

33
![License](https://img.shields.io/github/license/appwrite/sdk-for-node.svg?style=flat-square)
4-
![Version](https://img.shields.io/badge/api%20version-1.6.1-blue.svg?style=flat-square)
4+
![Version](https://img.shields.io/badge/api%20version-1.6.2-blue.svg?style=flat-square)
55
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
66
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
77
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)

docs/examples/databases/update-float-attribute.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ const result = await databases.updateFloatAttribute(
1212
'<COLLECTION_ID>', // collectionId
1313
'', // key
1414
false, // required
15-
null, // min
16-
null, // max
1715
null, // default
16+
null, // min (optional)
17+
null, // max (optional)
1818
'' // newKey (optional)
1919
);

docs/examples/databases/update-integer-attribute.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ const result = await databases.updateIntegerAttribute(
1212
'<COLLECTION_ID>', // collectionId
1313
'', // key
1414
false, // required
15-
null, // min
16-
null, // max
1715
null, // default
16+
null, // min (optional)
17+
null, // max (optional)
1818
'' // newKey (optional)
1919
);

docs/examples/health/get-queue-usage-dump.md renamed to docs/examples/health/get-queue-stats-resources.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ const client = new sdk.Client()
77

88
const health = new sdk.Health(client);
99

10-
const result = await health.getQueueUsageDump(
10+
const result = await health.getQueueStatsResources(
1111
null // threshold (optional)
1212
);

docs/examples/health/get-queue.md

Lines changed: 0 additions & 10 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "node-appwrite",
33
"homepage": "https://appwrite.io/support",
44
"description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API",
5-
"version": "15.0.1",
5+
"version": "16.0.0",
66
"license": "BSD-3-Clause",
77
"main": "dist/index.js",
88
"type": "commonjs",

src/client.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class AppwriteException extends Error {
3333
}
3434

3535
function getUserAgent() {
36-
let ua = 'AppwriteNodeJSSDK/15.0.1';
36+
let ua = 'AppwriteNodeJSSDK/16.0.0';
3737

3838
// `process` is a global in Node.js, but not fully available in all runtimes.
3939
const platform: string[] = [];
@@ -82,7 +82,7 @@ class Client {
8282
'x-sdk-name': 'Node.js',
8383
'x-sdk-platform': 'server',
8484
'x-sdk-language': 'nodejs',
85-
'x-sdk-version': '15.0.1',
85+
'x-sdk-version': '16.0.0',
8686
'user-agent' : getUserAgent(),
8787
'X-Appwrite-Response-Format': '1.6.0',
8888
};
@@ -97,8 +97,11 @@ class Client {
9797
* @returns {this}
9898
*/
9999
setEndpoint(endpoint: string): this {
100-
this.config.endpoint = endpoint;
100+
if (!endpoint.startsWith('http://') && !endpoint.startsWith('https://')) {
101+
throw new AppwriteException('Invalid endpoint URL: ' + endpoint);
102+
}
101103

104+
this.config.endpoint = endpoint;
102105
return this;
103106
}
104107

@@ -265,6 +268,10 @@ class Client {
265268
async chunkedUpload(method: string, url: URL, headers: Headers = {}, originalPayload: Payload = {}, onProgress: (progress: UploadProgress) => void) {
266269
const file = Object.values(originalPayload).find((value) => value instanceof File);
267270

271+
if (!file) {
272+
throw new Error('File not found in payload');
273+
}
274+
268275
if (file.size <= Client.CHUNK_SIZE) {
269276
return await this.call(method, url, headers, originalPayload);
270277
}
@@ -328,7 +335,6 @@ class Client {
328335
const { uri, options } = this.prepareRequest(method, url, headers, params);
329336

330337
let data: any = null;
331-
let text: string = '';
332338

333339
const response = await fetch(uri, options);
334340

@@ -339,18 +345,22 @@ class Client {
339345

340346
if (response.headers.get('content-type')?.includes('application/json')) {
341347
data = await response.json();
342-
text = JSON.stringify(data);
343348
} else if (responseType === 'arrayBuffer') {
344349
data = await response.arrayBuffer();
345350
} else {
346-
text = await response.text();
347351
data = {
348-
message: text
352+
message: await response.text()
349353
};
350354
}
351355

352356
if (400 <= response.status) {
353-
throw new AppwriteException(data?.message, response.status, data?.type, text);
357+
let responseText = '';
358+
if (response.headers.get('content-type')?.includes('application/json') || responseType === 'arrayBuffer') {
359+
responseText = JSON.stringify(data);
360+
} else {
361+
responseText = data?.message;
362+
}
363+
throw new AppwriteException(data?.message, response.status, data?.type, responseText);
354364
}
355365

356366
return data;

src/enums/credit-card.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ export enum CreditCard {
1515
Visa = 'visa',
1616
MIR = 'mir',
1717
Maestro = 'maestro',
18+
Rupay = 'rupay',
1819
}

src/enums/name.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ export enum Name {
44
V1audits = 'v1-audits',
55
V1mails = 'v1-mails',
66
V1functions = 'v1-functions',
7-
V1usage = 'v1-usage',
8-
V1usagedump = 'v1-usage-dump',
7+
V1statsresources = 'v1-stats-resources',
8+
V1statsusage = 'v1-stats-usage',
99
V1webhooks = 'v1-webhooks',
1010
V1certificates = 'v1-certificates',
1111
V1builds = 'v1-builds',

src/enums/o-auth-provider.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export enum OAuthProvider {
1313
Dropbox = 'dropbox',
1414
Etsy = 'etsy',
1515
Facebook = 'facebook',
16+
Figma = 'figma',
1617
Github = 'github',
1718
Gitlab = 'gitlab',
1819
Google = 'google',

0 commit comments

Comments
 (0)