diff options
Diffstat (limited to 'server/model/heartbeat.js')
-rw-r--r-- | server/model/heartbeat.js | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/server/model/heartbeat.js b/server/model/heartbeat.js new file mode 100644 index 0000000..9e972a3 --- /dev/null +++ b/server/model/heartbeat.js @@ -0,0 +1,45 @@ +const { BeanModel } = require("redbean-node/dist/bean-model"); + +/** + * status: + * 0 = DOWN + * 1 = UP + * 2 = PENDING + * 3 = MAINTENANCE + */ +class Heartbeat extends BeanModel { + + /** + * Return an object that ready to parse to JSON for public + * Only show necessary data to public + * @returns {object} Object ready to parse + */ + toPublicJSON() { + return { + status: this.status, + time: this.time, + msg: "", // Hide for public + ping: this.ping, + }; + } + + /** + * Return an object that ready to parse to JSON + * @returns {object} Object ready to parse + */ + toJSON() { + return { + monitorID: this._monitorId, + status: this._status, + time: this._time, + msg: this._msg, + ping: this._ping, + important: this._important, + duration: this._duration, + retries: this._retries, + }; + } + +} + +module.exports = Heartbeat; |