ConfigManager.migrateConfig() was called but never defined — would crash at runtime. Added config version checking, migration support, and fixed createEndpoint indentation. New formatters module (csv, influxdb, json) for pluggable output formatting. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
23 lines
631 B
JavaScript
23 lines
631 B
JavaScript
/**
|
|
* JSON formatter
|
|
* Produces a JSON string suitable for MQTT, REST APIs, etc.
|
|
*
|
|
* @param {string} measurement - The measurement name (e.g. node name)
|
|
* @param {object} metadata - { fields, tags }
|
|
* - fields: key/value pairs of changed data points
|
|
* - tags: flat key/value string pairs
|
|
* @returns {string} JSON-encoded string
|
|
*/
|
|
function format(measurement, metadata) {
|
|
const { fields, tags } = metadata;
|
|
const payload = {
|
|
measurement: measurement,
|
|
fields: fields,
|
|
tags: tags || {},
|
|
timestamp: new Date().toISOString(),
|
|
};
|
|
return JSON.stringify(payload);
|
|
}
|
|
|
|
module.exports = { format };
|