Issue: Replace CLI invocation of Node script with direct module import and function call
Description:
The current implementation executes a Node.js script as a separate process:
const runner = spawn('node', ['/root/bin/js/runner.js', 'authenticateUser', username, password]);
This approach treats a JavaScript file as a command-line tool rather than a reusable module.
Recommendation:
Refactor runner.js to export its functions and import it directly where needed, for example:
const { authenticateUser } = require('/root/bin/js/runner');
authenticateUser(username, password);
Benefits:
- Eliminates unnecessary process spawning overhead
- Improves performance and error handling
- Enables direct access to function results and exceptions
- Simplifies testing and maintenance