-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnode_helper.js
51 lines (47 loc) · 1.41 KB
/
node_helper.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
39
40
41
42
43
44
45
46
47
48
49
50
51
/**
* @file node_helper.js
* @description Node helper for MMM-Birthday module
* @author Christian Gillinger
* @license MIT
* @version 1.0.0
*
* Provides backend support for the MMM-Birthday module.
* Handles initialization and error management.
*/
var NodeHelper = require("node_helper");
module.exports = NodeHelper.create({
/**
* @function start
* @description Called when the helper starts
*/
start: function() {
console.log("Starting node helper for: " + this.name);
this.initialized = false;
},
/**
* @function socketNotificationReceived
* @description Handle incoming socket notifications
* @param {string} notification - The notification identifier
* @param {*} payload - The notification payload
*/
socketNotificationReceived: function(notification, payload) {
if (notification === "INITIALIZE") {
if (!this.initialized) {
this.initialized = true;
this.sendSocketNotification("INITIALIZED", true);
}
}
},
/**
* @function handleError
* @description Handle and log errors
* @param {Error} error - The error object
*/
handleError: function(error) {
console.error(`[${this.name}] Error:`, error);
this.sendSocketNotification("ERROR", {
message: error.message,
stack: error.stack
});
}
});