-
Notifications
You must be signed in to change notification settings - Fork 0
/
groq-config.js
38 lines (30 loc) · 1.46 KB
/
groq-config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
module.exports = function(RED) {
// Define the configuration node for GROQ
function GroqConfigNode(config) {
// Initialize the node with the configuration provided
RED.nodes.createNode(this, config);
const node = this;
// Assign the name from the configuration to the node
node.name = config.name;
// Initialize credentials object if not already set
node.credentials = this.credentials || {}; // Placeholder for credentials (API Key)
// The API key can be accessed via this.credentials.apiKey
// Event handler for when the node is closed (e.g., deleted or redeployed)
node.on('close', (removed, done) => {
// Perform any necessary cleanup actions here
if (removed) {
// This block executes if the node is being deleted
// Add any specific cleanup logic for node deletion if needed
}
// Signal that the cleanup process is complete
done(); // Signal that cleanup is done
});
}
// Register the configuration node with Node-RED
RED.nodes.registerType("groq-config", GroqConfigNode, {
// Define the credentials that this node will use
credentials: {
apiKey: { type: "password" } // Define 'apiKey' as a password type for secure storage
}
});
}