feat: implement thread-safe node registry and registration endpoints for Lora nodes

This commit is contained in:
Will Miao
2025-06-26 18:31:14 +08:00
parent ae905c8630
commit eb57e04e95
3 changed files with 191 additions and 0 deletions

View File

@@ -195,6 +195,32 @@ app.registerExtension({
isUpdating = false;
}
};
// Register this node with the backend
this.registerNode = async () => {
try {
await fetch('/api/register-node', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
node_id: this.id,
bgcolor: this.bgcolor,
title: this.title,
graph_id: this.graph.id
})
});
} catch (error) {
console.warn('Failed to register node:', error);
}
};
// Ensure the node is registered after creation
// Call registration
setTimeout(() => {
this.registerNode();
}, 0);
});
}
},

View File

@@ -125,6 +125,31 @@ app.registerExtension({
isUpdating = false;
}
};
// Register this node with the backend
this.registerNode = async () => {
try {
await fetch('/api/register-node', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
node_id: this.id,
bgcolor: this.bgcolor,
title: this.title,
graph_id: this.graph.id
})
});
} catch (error) {
console.warn('Failed to register node:', error);
}
};
// Call registration
setTimeout(() => {
this.registerNode();
}, 0);
});
}
},