Skip to content

Commit

Permalink
Update package-lock.json, package.json, and source files, adding new …
Browse files Browse the repository at this point in the history
…dependencies

Added "@types/node-red" to the list of devDependencies. Also updated package-lock.json with newly resolved and installed packages. The source files also have added typescript and Node-RED elements for better debugging and error handling capabilities. This will enhance the project's development experience and reliability.
  • Loading branch information
ng-galien committed Jan 1, 2024
1 parent bda260d commit bdef810
Show file tree
Hide file tree
Showing 4 changed files with 237 additions and 3 deletions.
209 changes: 209 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"uuid": "^9.0.1"
},
"devDependencies": {
"@types/node-red": "^1.3.4",
"axios": "^1.6.3",
"chai": "^4.3.10",
"chai-wait-for": "^1.1.0",
Expand Down
10 changes: 9 additions & 1 deletion src/pulsar-config.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@

<script type="text/javascript">
console.log("register pulsar-config");

import { EditorRED } from '@types/node-red';
/**
* @type {EditorRED}
*/

const RED = global.RED;

RED.nodes.registerType('pulsar-config', {
category: 'config',
color: '#188fff',
Expand Down
20 changes: 18 additions & 2 deletions src/pulsar-config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// <reference types="pulsar-client" />
const Pulsar = require('pulsar-client');

module.exports = function(RED) {
Expand All @@ -18,7 +19,20 @@ module.exports = function(RED) {
try {

Pulsar.Client.setLogHandler((level, file, line, message) => {
console.log(level, file, line, message);
switch (level) {
case Pulsar.LogLevel.DEBUG:
node.debug(message);
break;
case Pulsar.LogLevel.INFO:
node.log(message);
break;
case Pulsar.LogLevel.WARN:
node.warn(message);
break;
case Pulsar.LogLevel.ERROR:
node.error(message);
break;
}
});
node.client = new Pulsar.Client({
serviceUrl: n.serviceUrl,
Expand All @@ -34,12 +48,14 @@ module.exports = function(RED) {
statsIntervalSeconds: n.statsIntervalSeconds
});
} catch (e) {
this.error('Error creating pulsar client: ' + e);
node.error('Error creating pulsar client: ' + e);
}
}

function buildAuthentication(authentication) {
return undefined;
}

RED.nodes.registerType("pulsar-config", PulsarConfigNode);
};

0 comments on commit bdef810

Please sign in to comment.