diff --git a/templates/node/src/client.ts.twig b/templates/node/src/client.ts.twig index 69f8eeb66..c9937444e 100644 --- a/templates/node/src/client.ts.twig +++ b/templates/node/src/client.ts.twig @@ -240,10 +240,8 @@ class Client { return response; } - async ping(): Promise<{ pingCount: number, pingedAt: Date }> { - return this.call('GET', new URL('/ping', this.config.endpoint), {}, { - 'projectId': this.config.projectId, - }, 'json'); + async ping(): Promise { + return this.call('GET', new URL('/ping', this.config.endpoint), {}, {}, 'json'); } async redirect(method: string, url: URL, headers: Headers = {}, params: Payload = {}): Promise { diff --git a/templates/web/src/client.ts.twig b/templates/web/src/client.ts.twig index 6828abb0f..1feb49ebd 100644 --- a/templates/web/src/client.ts.twig +++ b/templates/web/src/client.ts.twig @@ -634,6 +634,10 @@ class Client { return response; } + async ping(): Promise { + return this.call('GET', new URL('/ping', this.config.endpoint), {}, {}, 'json'); + } + async call(method: string, url: URL, headers: Headers = {}, params: Payload = {}, responseType = 'json'): Promise { const { uri, options } = this.prepareRequest(method, url, headers, params); diff --git a/tests/WebChromiumTest.php b/tests/WebChromiumTest.php index 129216f73..781555d1c 100644 --- a/tests/WebChromiumTest.php +++ b/tests/WebChromiumTest.php @@ -21,6 +21,7 @@ class WebChromiumTest extends Base 'docker run --network="mockapi" --rm -v $(pwd):/app -e BROWSER=chromium -w /app/tests/sdks/web mcr.microsoft.com/playwright:v1.15.0-focal node tests.js'; protected array $expectedOutput = [ + ...Base::PING_RESPONSE, ...Base::FOO_RESPONSES, ...Base::BAR_RESPONSES, ...Base::GENERAL_RESPONSES, diff --git a/tests/WebNodeTest.php b/tests/WebNodeTest.php index afeb0eb8b..7be74f286 100644 --- a/tests/WebNodeTest.php +++ b/tests/WebNodeTest.php @@ -22,6 +22,7 @@ class WebNodeTest extends Base 'docker run --network="mockapi" --rm -v $(pwd):/app -w /app/tests/sdks/web node:18-alpine node node.js'; protected array $expectedOutput = [ + ...Base::PING_RESPONSE, ...Base::FOO_RESPONSES, ...Base::BAR_RESPONSES, ...Base::GENERAL_RESPONSES, diff --git a/tests/languages/web/index.html b/tests/languages/web/index.html index e3fcfe1f5..bfd18f082 100644 --- a/tests/languages/web/index.html +++ b/tests/languages/web/index.html @@ -19,6 +19,7 @@ document.getElementById("start").addEventListener("click", async () => { let response; let responseRealtime = 'Realtime failed!'; + // Init SDK const { Client, Foo, Bar, General, Query, Permission, Role, ID, MockType } = Appwrite; const client = new Client(); @@ -27,6 +28,12 @@ const bar = new Bar(client); const general = new General(client); + // Ping + client.setProject('123456'); + response = await client.ping(); + console.log(response.result); + + // Realtime setup client.setProject('console'); client.setEndpointRealtime('ws://demo.appwrite.io/v1'); diff --git a/tests/languages/web/node.js b/tests/languages/web/node.js index 590779735..508a05d39 100644 --- a/tests/languages/web/node.js +++ b/tests/languages/web/node.js @@ -5,9 +5,15 @@ async function start() { console.log('\nTest Started'); const client = new Client(); + client.setProject('123456'); const foo = new Foo(client); const bar = new Bar(client); const general = new General(client); + + // Ping + response = await client.ping(); + console.log(response.result); + // Foo response = await foo.get('string', 123, ['string in array']); console.log(response.result);