Skip to content

Commit 9f8dad3

Browse files
committed
feat: dynamic RPC servers data loading
1 parent 17f457e commit 9f8dad3

File tree

2 files changed

+84
-6
lines changed

2 files changed

+84
-6
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { defineLoader } from 'vitepress'
2+
3+
export interface RpcServer {
4+
name: string
5+
endpoint: string
6+
maintainer: string
7+
statusLink: string | null
8+
network: 'mainnet' | 'testnet'
9+
description: string
10+
}
11+
12+
export interface RpcServersData {
13+
mainnet: RpcServer[]
14+
testnet: RpcServer[]
15+
}
16+
17+
declare const data: RpcServersData
18+
export { data }
19+
20+
export default defineLoader({
21+
async load(): Promise<RpcServersData> {
22+
const response = await fetch('https://raw.githubusercontent.com/onmax/nimiq-awesome/main/src/data/dist/rpc-servers.json')
23+
24+
if (!response.ok) {
25+
throw new Error(`Failed to fetch RPC servers data: ${response.statusText}`)
26+
}
27+
28+
const data = await response.json() as RpcServersData
29+
30+
// Validate the data structure
31+
if (!data.mainnet || !data.testnet) {
32+
throw new Error('Invalid RPC servers data structure')
33+
}
34+
35+
return data
36+
},
37+
})

rpc-client/open-servers.md

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,59 @@ Public Nimiq RPC servers available for testing, development, and prototyping.
88
99
### Mainnet
1010

11-
| Server | HTTP Endpoint | Maintainer | Status & Limits |
12-
|---|---|---|---|
13-
| **NimiqWatch** | `https://rpc.nimiqwatch.com` | [@sisou](https://github.com/sisou) | [More details](https://rpc.nimiqwatch.com/){.nq-arrow} |
11+
<div class="table-container">
12+
<table>
13+
<thead>
14+
<tr>
15+
<th>Server</th>
16+
<th>HTTP Endpoint</th>
17+
<th>Maintainer</th>
18+
<th>Status & Limits</th>
19+
</tr>
20+
</thead>
21+
<tbody>
22+
<tr v-for="server in data.mainnet" :key="server.endpoint">
23+
<td><strong>{{ server.name }}</strong></td>
24+
<td><code>{{ server.endpoint }}</code></td>
25+
<td>{{ server.maintainer }}</td>
26+
<td>
27+
<a v-if="server.statusLink" :href="server.statusLink" class="nq-arrow">More details</a>
28+
<span v-else>-</span>
29+
</td>
30+
</tr>
31+
</tbody>
32+
</table>
33+
</div>
1434

1535
### Testnet
1636

17-
| Server | HTTP Endpoint | Maintainer | Status & Limits |
18-
|---|---|---|---|
19-
| **NimiqWatch** | `https://rpc.testnet.nimiqwatch.com/` | [@sisou](https://github.com/sisou) | [More details](https://rpc.testnet.nimiqwatch.com/){.nq-arrow} |
37+
<div class="table-container">
38+
<table>
39+
<thead>
40+
<tr>
41+
<th>Server</th>
42+
<th>HTTP Endpoint</th>
43+
<th>Maintainer</th>
44+
<th>Status & Limits</th>
45+
</tr>
46+
</thead>
47+
<tbody>
48+
<tr v-for="server in data.testnet" :key="server.endpoint">
49+
<td><strong>{{ server.name }}</strong></td>
50+
<td><code>{{ server.endpoint }}</code></td>
51+
<td>{{ server.maintainer }}</td>
52+
<td>
53+
<a v-if="server.statusLink" :href="server.statusLink" class="nq-arrow">More details</a>
54+
<span v-else>-</span>
55+
</td>
56+
</tr>
57+
</tbody>
58+
</table>
59+
</div>
2060

2161
<script setup lang="ts">
2262
import Banner from '../.vitepress/theme/components/Banner.vue'
63+
import { data } from '../.vitepress/data/rpc-servers.data'
2364
</script>
2465

2566
<Banner

0 commit comments

Comments
 (0)