From 78febed05cf1ef96e4575909c76d6d5e03d4afb9 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Thu, 17 Apr 2025 19:47:05 +0100 Subject: [PATCH] fix: remove content-type from GET requests --- README.md | 2 +- package.json | 2 +- src/client.ts | 13 ++++++++++--- src/enums/o-auth-provider.ts | 1 + src/services/account.ts | 8 -------- src/services/databases.ts | 2 -- src/services/functions.ts | 2 -- src/services/locale.ts | 8 -------- src/services/storage.ts | 2 -- src/services/teams.ts | 5 ----- 10 files changed, 13 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 66d8ec22..3f24ffcd 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Appwrite React Native SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-react-native.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.6.1-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.6.2-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) diff --git a/package.json b/package.json index 64c51f84..5ff33cff 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "react-native-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": "0.7.2", + "version": "0.7.3", "license": "BSD-3-Clause", "main": "dist/cjs/sdk.js", "exports": { diff --git a/src/client.ts b/src/client.ts index 5bfa8299..fb3e96a5 100644 --- a/src/client.ts +++ b/src/client.ts @@ -114,7 +114,7 @@ class Client { 'x-sdk-name': 'React Native', 'x-sdk-platform': 'client', 'x-sdk-language': 'reactnative', - 'x-sdk-version': '0.7.2', + 'x-sdk-version': '0.7.3', 'X-Appwrite-Response-Format': '1.6.0', }; @@ -128,8 +128,12 @@ class Client { * @returns {this} */ setEndpoint(endpoint: string): this { + if (!endpoint.startsWith('http://') && !endpoint.startsWith('https://')) { + throw new AppwriteException('Invalid endpoint URL: ' + endpoint); + } + this.config.endpoint = endpoint; - this.config.endpointRealtime = this.config.endpointRealtime || this.config.endpoint.replace('https://', 'wss://').replace('http://', 'ws://'); + this.config.endpointRealtime = endpoint.replace('https://', 'wss://').replace('http://', 'ws://'); return this; } @@ -142,8 +146,11 @@ class Client { * @returns {this} */ setEndpointRealtime(endpointRealtime: string): this { - this.config.endpointRealtime = endpointRealtime; + if (!endpointRealtime.startsWith('ws://') && !endpointRealtime.startsWith('wss://')) { + throw new AppwriteException('Invalid realtime endpoint URL: ' + endpointRealtime); + } + this.config.endpointRealtime = endpointRealtime; return this; } diff --git a/src/enums/o-auth-provider.ts b/src/enums/o-auth-provider.ts index b2bf4d16..7a3fcb3f 100644 --- a/src/enums/o-auth-provider.ts +++ b/src/enums/o-auth-provider.ts @@ -13,6 +13,7 @@ export enum OAuthProvider { Dropbox = 'dropbox', Etsy = 'etsy', Facebook = 'facebook', + Figma = 'figma', Github = 'github', Gitlab = 'gitlab', Google = 'google', diff --git a/src/services/account.ts b/src/services/account.ts index 7c4927d5..bcd37339 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -28,7 +28,6 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -144,7 +143,6 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -207,7 +205,6 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -390,7 +387,6 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -409,7 +405,6 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -559,7 +554,6 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -696,7 +690,6 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -959,7 +952,6 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } diff --git a/src/services/databases.ts b/src/services/databases.ts index a6367fcb..23b0fad0 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -41,7 +41,6 @@ export class Databases extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -131,7 +130,6 @@ export class Databases extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } diff --git a/src/services/functions.ts b/src/services/functions.ts index 89aa791a..d278537a 100644 --- a/src/services/functions.ts +++ b/src/services/functions.ts @@ -42,7 +42,6 @@ export class Functions extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -122,7 +121,6 @@ export class Functions extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } }; diff --git a/src/services/locale.ts b/src/services/locale.ts index 6a99b833..6498bd98 100644 --- a/src/services/locale.ts +++ b/src/services/locale.ts @@ -30,7 +30,6 @@ export class Locale extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -47,7 +46,6 @@ export class Locale extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -64,7 +62,6 @@ export class Locale extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -81,7 +78,6 @@ export class Locale extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -98,7 +94,6 @@ export class Locale extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -115,7 +110,6 @@ export class Locale extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -133,7 +127,6 @@ export class Locale extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -150,7 +143,6 @@ export class Locale extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } }; diff --git a/src/services/storage.ts b/src/services/storage.ts index 5101f7d8..3b1ac8a8 100644 --- a/src/services/storage.ts +++ b/src/services/storage.ts @@ -43,7 +43,6 @@ export class Storage extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -185,7 +184,6 @@ export class Storage extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } diff --git a/src/services/teams.ts b/src/services/teams.ts index 8eb69e1f..98e459f6 100644 --- a/src/services/teams.ts +++ b/src/services/teams.ts @@ -36,7 +36,6 @@ export class Teams extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -98,7 +97,6 @@ export class Teams extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -183,7 +181,6 @@ export class Teams extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -286,7 +283,6 @@ export class Teams extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -425,7 +421,6 @@ export class Teams extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); }