Skip to content

Commit e4a355c

Browse files
authored
docs: add POST /info endpoint to update master alias in API documentation
1 parent 22f541c commit e4a355c

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

docs/en/api.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ nodepass "master://0.0.0.0:9090/admin?log=info&tls=1"
4242
| `/instances/{id}` | DELETE | Delete instance |
4343
| `/events` | GET | SSE real-time event stream |
4444
| `/info` | GET | Get master service info |
45+
| `/info` | POST | Update master alias |
4546
| `/tcping` | GET | TCP connection test |
4647
| `/openapi.json` | GET | OpenAPI specification |
4748
| `/docs` | GET | Swagger UI documentation |
@@ -900,6 +901,7 @@ The response contains the following system information fields:
900901
901902
```json
902903
{
904+
"alias": "dev", // Master alias
903905
"os": "linux", // Operating system type
904906
"arch": "amd64", // System architecture
905907
"cpu": 45, // CPU usage percentage (Linux only)
@@ -1145,6 +1147,28 @@ await fetch(`${API_URL}/instances/abc123`, {
11451147
- **Authentication**: Requires API Key
11461148
- **Response**: Contains system information, version, uptime, CPU and RAM usage, etc.
11471149
1150+
#### POST /info
1151+
- **Description**: Update master alias
1152+
- **Authentication**: Requires API Key
1153+
- **Request body**: `{ "alias": "new alias" }`
1154+
- **Response**: Complete master information (same as GET /info)
1155+
- **Example**:
1156+
```javascript
1157+
// Update master alias
1158+
const response = await fetch(`${API_URL}/info`, {
1159+
method: 'POST',
1160+
headers: {
1161+
'Content-Type': 'application/json',
1162+
'X-API-Key': apiKey
1163+
},
1164+
body: JSON.stringify({ alias: 'My NodePass Server' })
1165+
});
1166+
1167+
const data = await response.json();
1168+
console.log('Updated alias:', data.alias);
1169+
// Response contains full system info with updated alias
1170+
```
1171+
11481172
#### GET /tcping
11491173
- **Description**: TCP connection test, checks connectivity and latency to target address
11501174
- **Authentication**: Requires API Key

docs/zh/api.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ nodepass "master://0.0.0.0:9090/admin?log=info&tls=1"
4242
| `/instances/{id}` | DELETE | 删除实例 |
4343
| `/events` | GET | SSE 实时事件流 |
4444
| `/info` | GET | 获取主控服务信息 |
45+
| `/info` | POST | 更新主控别名 |
4546
| `/tcping` | GET | TCP连接测试 |
4647
| `/openapi.json` | GET | OpenAPI 规范 |
4748
| `/docs` | GET | Swagger UI 文档 |
@@ -899,6 +900,7 @@ GET /info
899900
900901
```json
901902
{
903+
"alias": "dev", // 主控别名
902904
"os": "linux", // 操作系统类型
903905
"arch": "amd64", // 系统架构
904906
"cpu": 45, // CPU使用率百分比(仅Linux系统)
@@ -1144,6 +1146,28 @@ await fetch(`${API_URL}/instances/abc123`, {
11441146
- **认证**:需要API Key
11451147
- **响应**:包含系统信息、版本、运行时间、CPU和RAM使用率等
11461148
1149+
#### POST /info
1150+
- **描述**:更新主控别名
1151+
- **认证**:需要API Key
1152+
- **请求体**:`{ "alias": "新别名" }`
1153+
- **响应**:完整的主控信息(与GET /info相同)
1154+
- **示例**:
1155+
```javascript
1156+
// 更新主控别名
1157+
const response = await fetch(`${API_URL}/info`, {
1158+
method: 'POST',
1159+
headers: {
1160+
'Content-Type': 'application/json',
1161+
'X-API-Key': apiKey
1162+
},
1163+
body: JSON.stringify({ alias: '我的NodePass服务器' })
1164+
});
1165+
1166+
const data = await response.json();
1167+
console.log('更新后的别名:', data.alias);
1168+
// 响应包含完整的系统信息,包括更新后的别名
1169+
```
1170+
11471171
#### GET /tcping
11481172
- **描述**:TCP连接测试,检测目标地址的连通性和延迟
11491173
- **认证**:需要API Key

0 commit comments

Comments
 (0)