MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / makeRequest

Function makeRequest

komari/komari.ts:219–240  ·  view source on GitHub ↗
(url: string, endpoint: string)

Source from the content-addressed store, hash-verified

217
218// HTTP 请求封装
219async function makeRequest(url: string, endpoint: string): Promise<any> {
220 try {
221 const response = await axios.get(`${url}${endpoint}`, {
222 timeout: 10000,
223 headers: {
224 Accept: "application/json",
225 "User-Agent": "TeleBox-Komari-Plugin/1.0",
226 },
227 });
228
229 if (response.status !== 200) {
230 throw new Error(`HTTP ${response.status}: ${response.statusText}`);
231 }
232
233 return response.data;
234 } catch (error: any) {
235 if (error.response) {
236 throw new Error(`API 请求失败: HTTP ${error.response.status}`);
237 }
238 throw new Error(`网络请求失败: ${error.message}`);
239 }
240}
241
242// 获取服务器基本信息
243async function getServerInfo(baseUrl: string): Promise<string> {

Callers 3

getServerInfoFunction · 0.85
getNodesOverviewFunction · 0.85
getNodeDetailsFunction · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected