@hitchy/plugin-odem-socket.io 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/services/odem/websocket-provider.js +7 -6
- package/package.json +10 -11
- package/readme.md +3 -3
|
@@ -7,8 +7,8 @@ module.exports = function() {
|
|
|
7
7
|
const logError = api.log( "hitchy:odem:socket.io:error" );
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* Implements API for controlling and monitoring server-side
|
|
11
|
-
* websocket.
|
|
10
|
+
* Implements API for controlling and monitoring server-side
|
|
11
|
+
* document-oriented database via websocket.
|
|
12
12
|
*/
|
|
13
13
|
class OdemWebsocketProvider {
|
|
14
14
|
/**
|
|
@@ -68,7 +68,7 @@ module.exports = function() {
|
|
|
68
68
|
* @param {boolean} enabled true if command handling is enabled in configuration
|
|
69
69
|
* @param {WebSocket} socket socket representing established incoming connection
|
|
70
70
|
* @param {string} modelName name of model to manage
|
|
71
|
-
* @param {class<Hitchy.Plugin.Odem.Model>} model
|
|
71
|
+
* @param {class<Hitchy.Plugin.Odem.Model>} model model instance based on document-oriented database to manage
|
|
72
72
|
* @returns {Object<string,function>} map of registered handler functions
|
|
73
73
|
*/
|
|
74
74
|
static handleModelRequests( enabled, socket, modelName, model ) {
|
|
@@ -120,13 +120,14 @@ module.exports = function() {
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
/**
|
|
123
|
-
* Sets up listeners for model-related notifications in
|
|
124
|
-
* them as broadcast events to
|
|
123
|
+
* Sets up listeners for model-related notifications in
|
|
124
|
+
* document-oriented database and forwards them as broadcast events to
|
|
125
|
+
* connected clients.
|
|
125
126
|
*
|
|
126
127
|
* @param {boolean} enabled true if command handling is enabled in configuration
|
|
127
128
|
* @param {Server} namespace namespace managing a list of server-side sockets with common prefix
|
|
128
129
|
* @param {string} modelName name of model to manage
|
|
129
|
-
* @param {class<Hitchy.Plugin.Odem.Model>} model
|
|
130
|
+
* @param {class<Hitchy.Plugin.Odem.Model>} model model instance of document-oriented database to manage
|
|
130
131
|
* @returns {Object<string,function>} map of registered handler functions
|
|
131
132
|
*/
|
|
132
133
|
static broadcastModelNotifications( enabled, namespace, modelName, model ) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hitchy/plugin-odem-socket.io",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "exposing Hitchy's
|
|
3
|
+
"version": "0.2.4",
|
|
4
|
+
"description": "exposing Hitchy's document-oriented database via websocket",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"lint": "eslint .",
|
|
@@ -14,8 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"keywords": [
|
|
16
16
|
"Hitchy",
|
|
17
|
-
"socket.io"
|
|
18
|
-
"ODM"
|
|
17
|
+
"socket.io"
|
|
19
18
|
],
|
|
20
19
|
"author": "cepharum GmbH",
|
|
21
20
|
"license": "MIT",
|
|
@@ -35,13 +34,13 @@
|
|
|
35
34
|
"@hitchy/plugin-socket.io": ">=0.1.1"
|
|
36
35
|
},
|
|
37
36
|
"devDependencies": {
|
|
38
|
-
"@hitchy/server-dev-tools": "^0.4.
|
|
39
|
-
"c8": "^
|
|
40
|
-
"eslint": "^8.
|
|
41
|
-
"eslint-config-cepharum": "^1.0.
|
|
42
|
-
"eslint-plugin-promise": "^
|
|
43
|
-
"mocha": "^10.
|
|
37
|
+
"@hitchy/server-dev-tools": "^0.4.9",
|
|
38
|
+
"c8": "^10.1.2",
|
|
39
|
+
"eslint": "^8.57.0",
|
|
40
|
+
"eslint-config-cepharum": "^1.0.14",
|
|
41
|
+
"eslint-plugin-promise": "^7.1.0",
|
|
42
|
+
"mocha": "^10.7.3",
|
|
44
43
|
"should": "^13.2.3",
|
|
45
|
-
"socket.io-client": "^4.7.
|
|
44
|
+
"socket.io-client": "^4.7.5"
|
|
46
45
|
}
|
|
47
46
|
}
|
package/readme.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @hitchy/plugin-odem-socket.io
|
|
2
2
|
|
|
3
|
-
_exposing Hitchy's
|
|
3
|
+
_exposing Hitchy's document-oriented database via websocket_
|
|
4
4
|
|
|
5
5
|
## License
|
|
6
6
|
|
|
@@ -29,7 +29,7 @@ npm i @hitchy/plugin-odem @hitchy/plugin-socket.io
|
|
|
29
29
|
|
|
30
30
|
### Basics
|
|
31
31
|
|
|
32
|
-
This plugin is establishing an API via websocket for controlling and monitoring models of server-side
|
|
32
|
+
This plugin is establishing an API via websocket for controlling and monitoring models of server-side document-oriented database. Relying on particular features of [socket.io](https://socket.io/), this API is exposed in [namespace](https://socket.io/docs/v4/namespaces/) `/hitchy/odem`.
|
|
33
33
|
|
|
34
34
|
For every server-side model, request listeners and/or notification broadcasters are set up. Either model's name is converted into its kebab-case variant and used as colon-separated prefix in event names emitted either by the server or by a client.
|
|
35
35
|
|
|
@@ -156,7 +156,7 @@ Last argument is a callback to be invoked with the resulting response from serve
|
|
|
156
156
|
|
|
157
157
|
### Notifications
|
|
158
158
|
|
|
159
|
-
[
|
|
159
|
+
[notifications of the document-oriented database](https://odem.hitchy.org/api/model.html#model-notifications) are forwarded as broadcast events named `<modelName>:changed`. Either event consists of
|
|
160
160
|
|
|
161
161
|
- a type of change and
|
|
162
162
|
- the changed item's properties (limited to its UUID on deletion).
|