mirror of
https://github.com/DeBrosOfficial/network-ts-sdk.git
synced 2025-12-11 01:58:49 +00:00
Refactor network status interface and update related tests; add dotenv for environment variable management
This commit is contained in:
parent
f2d8d35a35
commit
acf9540daa
11
package.json
11
package.json
@ -36,12 +36,13 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^20.0.0",
|
"@types/node": "^20.0.0",
|
||||||
"typescript": "^5.3.0",
|
|
||||||
"tsup": "^8.0.0",
|
|
||||||
"vitest": "^1.0.0",
|
|
||||||
"eslint": "^8.0.0",
|
|
||||||
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
||||||
"@typescript-eslint/parser": "^6.0.0"
|
"@typescript-eslint/parser": "^6.0.0",
|
||||||
|
"dotenv": "^17.2.3",
|
||||||
|
"eslint": "^8.0.0",
|
||||||
|
"tsup": "^8.0.0",
|
||||||
|
"typescript": "^5.3.0",
|
||||||
|
"vitest": "^1.0.0"
|
||||||
},
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"registry": "https://registry.npmjs.org/",
|
"registry": "https://registry.npmjs.org/",
|
||||||
|
|||||||
9
pnpm-lock.yaml
generated
9
pnpm-lock.yaml
generated
@ -21,6 +21,9 @@ importers:
|
|||||||
'@typescript-eslint/parser':
|
'@typescript-eslint/parser':
|
||||||
specifier: ^6.0.0
|
specifier: ^6.0.0
|
||||||
version: 6.21.0(eslint@8.57.1)(typescript@5.9.3)
|
version: 6.21.0(eslint@8.57.1)(typescript@5.9.3)
|
||||||
|
dotenv:
|
||||||
|
specifier: ^17.2.3
|
||||||
|
version: 17.2.3
|
||||||
eslint:
|
eslint:
|
||||||
specifier: ^8.0.0
|
specifier: ^8.0.0
|
||||||
version: 8.57.1
|
version: 8.57.1
|
||||||
@ -744,6 +747,10 @@ packages:
|
|||||||
resolution: {integrity: sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==}
|
resolution: {integrity: sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==}
|
||||||
engines: {node: '>=6.0.0'}
|
engines: {node: '>=6.0.0'}
|
||||||
|
|
||||||
|
dotenv@17.2.3:
|
||||||
|
resolution: {integrity: sha512-JVUnt+DUIzu87TABbhPmNfVdBDt18BLOWjMUFJMSi/Qqg7NTYtabbvSNJGOJ7afbRuv9D/lngizHtP7QyLQ+9w==}
|
||||||
|
engines: {node: '>=12'}
|
||||||
|
|
||||||
eastasianwidth@0.2.0:
|
eastasianwidth@0.2.0:
|
||||||
resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==}
|
resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==}
|
||||||
|
|
||||||
@ -2054,6 +2061,8 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
esutils: 2.0.3
|
esutils: 2.0.3
|
||||||
|
|
||||||
|
dotenv@17.2.3: {}
|
||||||
|
|
||||||
eastasianwidth@0.2.0: {}
|
eastasianwidth@0.2.0: {}
|
||||||
|
|
||||||
emoji-regex@8.0.0: {}
|
emoji-regex@8.0.0: {}
|
||||||
|
|||||||
@ -7,9 +7,11 @@ export interface PeerInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface NetworkStatus {
|
export interface NetworkStatus {
|
||||||
healthy: boolean;
|
node_id: string;
|
||||||
peers: number;
|
connected: boolean;
|
||||||
uptime?: number;
|
peer_count: number;
|
||||||
|
database_size: number;
|
||||||
|
uptime: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class NetworkClient {
|
export class NetworkClient {
|
||||||
@ -35,7 +37,7 @@ export class NetworkClient {
|
|||||||
* Get network status.
|
* Get network status.
|
||||||
*/
|
*/
|
||||||
async status(): Promise<NetworkStatus> {
|
async status(): Promise<NetworkStatus> {
|
||||||
const response = await this.httpClient.get<NetworkStatus>("/v1/status");
|
const response = await this.httpClient.get<NetworkStatus>("/v1/network/status");
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -18,8 +18,8 @@ describe("Network", () => {
|
|||||||
const client = await createTestClient();
|
const client = await createTestClient();
|
||||||
const status = await client.network.status();
|
const status = await client.network.status();
|
||||||
expect(status).toBeDefined();
|
expect(status).toBeDefined();
|
||||||
expect(typeof status.healthy).toBe("boolean");
|
expect(typeof status.connected).toBe("boolean");
|
||||||
expect(typeof status.peers).toBe("number");
|
expect(typeof status.peer_count).toBe("number");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should list peers", async () => {
|
it("should list peers", async () => {
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
import { defineConfig } from "vitest/config";
|
import { defineConfig } from "vitest/config";
|
||||||
|
import dotenv from "dotenv";
|
||||||
|
|
||||||
|
dotenv.config();
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
test: {
|
test: {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user