Includes: - 3 Node.js actions (hello, http_example, read_counter) - 1 counter trigger type - 1 counter sensor (Node.js, keystore-backed, per-rule state) - 1 example rule (count_and_log) - package.json with node-fetch and amqplib - README with full usage documentation
31 lines
764 B
JavaScript
31 lines
764 B
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Hello Action - Node.js Example Pack
|
|
*
|
|
* A minimal Node.js action that returns "Hello, Node.js".
|
|
* Demonstrates the basic structure of a Node.js action in Attune.
|
|
*
|
|
* When invoked via the Node.js wrapper, the `run` export is called
|
|
* with the action parameters as its argument.
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
/**
|
|
* Return a simple greeting message.
|
|
* @param {object} params - Action parameters (unused).
|
|
* @returns {{ message: string }}
|
|
*/
|
|
function run(params) {
|
|
return { message: "Hello, Node.js" };
|
|
}
|
|
|
|
// Direct execution support (without the wrapper)
|
|
if (require.main === module) {
|
|
const result = run({});
|
|
process.stdout.write(JSON.stringify({ result, status: "success" }) + "\n");
|
|
process.exit(0);
|
|
}
|
|
|
|
module.exports = { run };
|