mirror of
https://github.com/balzack/databag.git
synced 2025-04-23 01:55:17 +00:00
added missing endpoints
This commit is contained in:
parent
103438b28a
commit
79c37761a9
11
app/sdk/src/net/clearLogin.ts
Normal file
11
app/sdk/src/net/clearLogin.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import axios from 'redaxios';
|
||||
|
||||
export async function clearLogin(node: string, secure: boolean, token: string, all: boolean): Promise<void> {
|
||||
const param = all ? '&all=true' : ''
|
||||
const endpoint = `http${secure ? 's' : ''}://${node}/account/apps?agent=${token}${param}`;
|
||||
const response = await axios.delete(endpoint);
|
||||
if (response.status >= 400 && response.stateus < 600) {
|
||||
throw new Error('clearLogin failed');
|
||||
}
|
||||
}
|
||||
|
14
app/sdk/src/net/getAvailable.ts
Normal file
14
app/sdk/src/net/getAvailable.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import axios from 'redaxios';
|
||||
|
||||
export async function getAvailable(node: string, secure: boolean): number {
|
||||
const endpoint = `http${secure ? 's' : ''}://${node}/account/available`;
|
||||
const response = await axios.get(endpoint);
|
||||
if (response.status >= 400 && response.status < 600) {
|
||||
throw new Error('getAvailable fetch failed');
|
||||
}
|
||||
if (typeof response.data !== 'number') {
|
||||
throw new Error('getAvailable response failed');
|
||||
}
|
||||
return response.data;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user