Skip to content

Commit 2a3a31a

Browse files
committed
refactored the block
1 parent 22f44ee commit 2a3a31a

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

templates/cli/lib/commands/generic.js.twig

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,20 +68,19 @@ const client = new Command("client")
6868
if (endpoint !== undefined) {
6969
try {
7070
let url = new URL(endpoint);
71-
if (url.protocol === "http:" || url.protocol === "https:") {
72-
let apClient = new Client().setEndpoint(endpoint);
73-
let response = await apClient.call('GET', '/health/version');
74-
if(response.version) {
75-
globalConfig.setEndpoint(endpoint);
76-
} else {
77-
throw new Error("Invalid endpoint or your Appwrite server is not running as expected.");
78-
}
79-
globalConfig.setEndpoint(endpoint);
80-
} else {
71+
if (url.protocol !== "http:" && url.protocol !== "https:") {
8172
throw new Error();
8273
}
74+
75+
let apClient = new Client().setEndpoint(endpoint);
76+
let response = await apClient.call('GET', '/health/version');
77+
if(!response.version) {
78+
throw new Error();
79+
}
80+
81+
globalConfig.setEndpoint(endpoint);
8382
} catch (_) {
84-
throw new Error("Invalid endpoint");
83+
throw new Error("Invalid endpoint or your Appwrite server is not running as expected.");
8584
}
8685
}
8786

0 commit comments

Comments
 (0)