Skip to content

Commit edbbd58

Browse files
committed
feat: node warnings
1 parent 74f0f05 commit edbbd58

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

templates/node/src/client.ts.twig

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@ type Headers = {
1818
[key: string]: string;
1919
}
2020

21-
function greaterThan(v1, v2) {
22-
const [a, b, c] = v1.split('.').map(Number);
23-
const [x, y, z] = v2.split('.').map(Number);
24-
return a > x || a === x && (b > y || b === y && c > z);
25-
}
26-
2721
class {{spec.title | caseUcfirst}}Exception extends Error {
2822
code: number;
2923
response: string;
@@ -268,10 +262,9 @@ class Client {
268262

269263
const response = await fetch(uri, options);
270264

271-
const defaultFormat = response.headers.get('x-appwrite-default-response-format');
272-
const sentFormat = headers['x-appwrite-response-format'];
273-
if (defaultFormat && sentFormat && greaterThan(sentFormat, defaultFormat)) {
274-
console.warn(`Request made with SDK version {{ sdk.version }} using response format ${sentFormat} while the server latest is ${defaultFormat}. This may lead to unexpected behavior. Please downgrade your SDK version to match the server default, see {{ sdk.gitURL }}/releases`);
265+
const warnings = response.headers.get('x-{{spec.title | lower}}-warning');
266+
if (warnings) {
267+
warnings.split(';').forEach((warning: string) => console.warn(warning));
275268
}
276269

277270
if (response.headers.get('content-type')?.includes('application/json')) {

0 commit comments

Comments
 (0)