Skip to content

Commit 1932b8e

Browse files
authored
Rename nodeEvent to event and update package usage (#5)
Renamed all references of 'nodeEvent' to 'event' in the client library and sample apps. Updated sample publisher and subscriber to use the '@nucleoidai/node-event' package instead of 'nuc-node-event-test'. Adjusted import paths and error messages accordingly.
1 parent 94ef7f1 commit 1932b8e

9 files changed

Lines changed: 67 additions & 67 deletions

File tree

client/Event.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ interface InitOptions {
44
protocol: string;
55
}
66
type Callback<T = any> = (payload: T) => void;
7-
declare const nodeEvent: {
7+
declare const event: {
88
init({ host, port, protocol }: InitOptions): void;
99
subscribe<T = any>(type: string, callback: Callback<T>): () => void;
1010
publish<T = any>(...args: [...string[], T]): void;
1111
};
12-
export { nodeEvent };
12+
export { event };

client/Event.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
3-
exports.nodeEvent = void 0;
3+
exports.event = void 0;
44
var socket_io_client_1 = require("socket.io-client");
55
var socket = null;
66
var callbacks = {};
7-
var nodeEvent = {
7+
var event = {
88
init: function (_a) {
99
var host = _a.host, port = _a.port, protocol = _a.protocol;
1010
if (socket)
@@ -19,7 +19,7 @@ var nodeEvent = {
1919
},
2020
subscribe: function (type, callback) {
2121
if (!socket)
22-
throw new Error("nodeEvent not initialized. Call nodeEvent.init first.");
22+
throw new Error("Event not initialized. Call event.init first.");
2323
if (!callbacks[type])
2424
callbacks[type] = new Set();
2525
callbacks[type].add(callback);
@@ -38,7 +38,7 @@ var nodeEvent = {
3838
args[_i] = arguments[_i];
3939
}
4040
if (!socket)
41-
throw new Error("nodeEvent not initialized. Call nodeEvent.init first.");
41+
throw new Error("Event not initialized. Call event.init first.");
4242
if (args.length < 2) {
4343
throw new Error("publish requires at least one event type and a payload");
4444
}
@@ -50,4 +50,4 @@ var nodeEvent = {
5050
});
5151
},
5252
};
53-
exports.nodeEvent = nodeEvent;
53+
exports.event = event;

client/Event.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ interface InitOptions {
1010
}
1111
type Callback<T = any> = (payload: T) => void;
1212

13-
const nodeEvent = {
13+
const event = {
1414
init({ host, port, protocol }: InitOptions) {
1515
if (socket) return;
1616
socket = io(`${protocol}://${host}:${port}`);
@@ -23,7 +23,7 @@ const nodeEvent = {
2323

2424
subscribe<T = any>(type: string, callback: Callback<T>): () => void {
2525
if (!socket)
26-
throw new Error("nodeEvent not initialized. Call nodeEvent.init first.");
26+
throw new Error("Event not initialized. Call event.init first.");
2727
if (!callbacks[type]) callbacks[type] = new Set();
2828
callbacks[type].add(callback as Callback);
2929
socket!.emit("subscribe", type);
@@ -38,7 +38,7 @@ const nodeEvent = {
3838

3939
publish<T = any>(...args: [...string[], T]): void {
4040
if (!socket)
41-
throw new Error("nodeEvent not initialized. Call nodeEvent.init first.");
41+
throw new Error("Event not initialized. Call event.init first.");
4242

4343
if (args.length < 2) {
4444
throw new Error("publish requires at least one event type and a payload");
@@ -54,4 +54,4 @@ const nodeEvent = {
5454
},
5555
};
5656

57-
export { nodeEvent };
57+
export { event };

sample/publisher/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
const express = require("express");
2-
const { nodeEvent } = require("nuc-node-event-test/client");
2+
const { event } = require("@nucleoidai/node-event/client");
33

44
const app = express();
55
app.use(express.json());
66

7-
nodeEvent.init({ host: "localhost", port: 8080 });
7+
event.init({ host: "localhost", port: 8080 });
88

99
app.post("/send", (req, res) => {
1010
const { type = "test", payload = {} } = req.body;
11-
nodeEvent.publish(type, payload);
11+
event.publish(type, payload);
1212
res.json({ status: "sent", type, payload });
1313
});
1414

sample/publisher/package-lock.json

Lines changed: 23 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sample/publisher/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"start": "node index.js"
77
},
88
"dependencies": {
9-
"express": "^4.18.2",
10-
"nuc-node-event-test": "^1.0.13"
9+
"@nucleoidai/node-event": "^1.1.1",
10+
"express": "^4.18.2"
1111
}
1212
}

sample/subscriber/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
const express = require('express');
2-
const { nodeEvent } = require('nuc-node-event-test/client');
2+
const { event } = require('@nucleoidai/node-event/client');
33

44
const app = express();
55

6-
nodeEvent.init({ host: 'localhost', port: 8080 });
6+
event.init({ host: 'localhost', port: 8080 });
77

8-
nodeEvent.subscribe('test', (payload) => {
8+
event.subscribe('test', (payload) => {
99
console.log('Received event:', payload);
1010
});
1111

sample/subscriber/package-lock.json

Lines changed: 23 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sample/subscriber/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"start": "node index.js"
77
},
88
"dependencies": {
9-
"express": "^4.18.2",
10-
"nuc-node-event-test": "^1.0.13"
9+
"@nucleoidai/node-event": "^1.1.1",
10+
"express": "^4.18.2"
1111
}
1212
}

0 commit comments

Comments
 (0)