@@ -12,7 +12,7 @@ const configPath = path.join(__dirname, "config.yml");
|
||||
const config = yaml.load(fs.readFileSync(configPath, "utf8"));
|
||||
|
||||
const PORT = config.server?.port || 4000;
|
||||
const HOSTS = config.targets?.hosts || ["http://127.0.0.1:7088"];
|
||||
const HOSTS = config.targets?.hosts || ["http://127.0.0.1:7088", name: "my-server"];
|
||||
const ENDPOINTS = config.targets?.endpoints || [];
|
||||
const TIMEOUT = config.targets?.timeout || 120_000;
|
||||
|
||||
@@ -52,7 +52,7 @@ app.post("/api/parallel-fetch", async (req, res) => {
|
||||
socket.emit("batch:start", { url, total: tasks.length });
|
||||
|
||||
const promises = tasks.map(({ host, endpoint }) => {
|
||||
const fullUrl = host + endpoint;
|
||||
const fullUrl = host.url + endpoint;
|
||||
const start = Date.now();
|
||||
|
||||
return axios({
|
||||
@@ -66,7 +66,9 @@ app.post("/api/parallel-fetch", async (req, res) => {
|
||||
const elapsed = Date.now() - start;
|
||||
console.log(`[OK] ${host} ${endpoint} (${elapsed}ms)`);
|
||||
socket.emit("tool:response", {
|
||||
host, endpoint,
|
||||
host: host.url,
|
||||
serverName: host.name,
|
||||
endpoint,
|
||||
ok: true,
|
||||
status: response.status,
|
||||
data: response.data,
|
||||
@@ -77,7 +79,9 @@ app.post("/api/parallel-fetch", async (req, res) => {
|
||||
const elapsed = Date.now() - start;
|
||||
console.log(`[ERROR] ${host} ${endpoint} (${elapsed}ms) — ${err.message}`);
|
||||
socket.emit("tool:error", {
|
||||
host, endpoint,
|
||||
host: host.url,
|
||||
serverName: host.name,
|
||||
endpoint,
|
||||
ok: false,
|
||||
error: err.message,
|
||||
code: err.code || null,
|
||||
|
||||
Reference in New Issue
Block a user