Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "node-appwrite",
"homepage": "https://appwrite.io/support",
"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",
"version": "15.0.0",
"version": "15.0.1",
"license": "BSD-3-Clause",
"main": "dist/index.js",
"type": "commonjs",
Expand Down
11 changes: 7 additions & 4 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class AppwriteException extends Error {
}

function getUserAgent() {
let ua = 'AppwriteNodeJSSDK/15.0.0';
let ua = 'AppwriteNodeJSSDK/15.0.1';

// `process` is a global in Node.js, but not fully available in all runtimes.
const platform: string[] = [];
Expand Down Expand Up @@ -82,7 +82,7 @@ class Client {
'x-sdk-name': 'Node.js',
'x-sdk-platform': 'server',
'x-sdk-language': 'nodejs',
'x-sdk-version': '15.0.0',
'x-sdk-version': '15.0.1',
'user-agent' : getUserAgent(),
'X-Appwrite-Response-Format': '1.6.0',
};
Expand Down Expand Up @@ -328,6 +328,7 @@ class Client {
const { uri, options } = this.prepareRequest(method, url, headers, params);

let data: any = null;
let text: string = '';

const response = await fetch(uri, options);

Expand All @@ -338,16 +339,18 @@ class Client {

if (response.headers.get('content-type')?.includes('application/json')) {
data = await response.json();
text = JSON.stringify(data);
} else if (responseType === 'arrayBuffer') {
data = await response.arrayBuffer();
} else {
text = await response.text();
data = {
message: await response.text()
message: text
};
}

if (400 <= response.status) {
throw new AppwriteException(data?.message, response.status, data?.type, data);
throw new AppwriteException(data?.message, response.status, data?.type, text);
}

return data;
Expand Down
4 changes: 2 additions & 2 deletions src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ export namespace Models {
/**
* Collection attributes.
*/
attributes: string[];
attributes: (Models.AttributeBoolean | Models.AttributeInteger | Models.AttributeFloat | Models.AttributeEmail | Models.AttributeEnum | Models.AttributeUrl | Models.AttributeIp | Models.AttributeDatetime | Models.AttributeRelationship | Models.AttributeString)[];
/**
* Collection indexes.
*/
Expand All @@ -460,7 +460,7 @@ export namespace Models {
/**
* List of attributes.
*/
attributes: string[];
attributes: (Models.AttributeBoolean | Models.AttributeInteger | Models.AttributeFloat | Models.AttributeEmail | Models.AttributeEnum | Models.AttributeUrl | Models.AttributeIp | Models.AttributeDatetime | Models.AttributeRelationship | Models.AttributeString)[];
}
/**
* AttributeString
Expand Down
Loading