ldn-inbox-server 1.4.3 → 1.4.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/README.md +1 -1
- package/config/inbox_config.json +7 -7
- package/config/outbox_config.json +2 -2
- package/lib/handler.js +9 -1
- package/lib/index.js +0 -1
- package/lib/util.js +2 -0
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -148,7 +148,7 @@ The json path matches when one of:
|
|
|
148
148
|
|
|
149
149
|
### Multi handler
|
|
150
150
|
|
|
151
|
-
A `handler/multi_notification_handler.js` is available to start multiple handler for each notification messages. The handlers to start are specified in a
|
|
151
|
+
A `handler/multi_notification_handler.js` is available to start multiple handler for each notification messages. The handlers to start are specified in a configuration file that can be passed via the `config` parameter of an `handle_inbox`. In the commmand line tool `bin/ldn-inbox-server` the default location of such config file is `config/inbox_config.json` when processing an `@inbox`, and `config/outbox_config.json` when processing an `@outbox`.
|
|
152
152
|
|
|
153
153
|
### Offer memento handler
|
|
154
154
|
|
package/config/inbox_config.json
CHANGED
|
@@ -4,21 +4,21 @@
|
|
|
4
4
|
"handlers": [
|
|
5
5
|
[
|
|
6
6
|
{
|
|
7
|
-
"id": "handler/notification_handler/jsonpath_filter.js",
|
|
7
|
+
"id": "@handler/notification_handler/jsonpath_filter.js",
|
|
8
8
|
"anyOf": [
|
|
9
9
|
[
|
|
10
10
|
{ "path": "$.type" , "value": "Offer" }
|
|
11
11
|
]
|
|
12
12
|
]
|
|
13
13
|
},
|
|
14
|
-
"handler/notification_handler/valid_artifact.js" ,
|
|
14
|
+
"@handler/notification_handler/valid_artifact.js" ,
|
|
15
15
|
{
|
|
16
|
-
"id": "handler/notification_handler/eventlog.js",
|
|
16
|
+
"id": "@handler/notification_handler/eventlog.js",
|
|
17
17
|
"log": "@artifact:strip@.jsonld",
|
|
18
18
|
"dir": "@artifact:strip@"
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
|
-
"id": "handler/notification_handler/offer_memento.js",
|
|
21
|
+
"id": "@handler/notification_handler/offer_memento.js",
|
|
22
22
|
"actor": {
|
|
23
23
|
"id": "http://localhost:8000/profile/card#me" ,
|
|
24
24
|
"inbox": "http://localhost:8000/inbox/" ,
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
] ,
|
|
34
34
|
[
|
|
35
35
|
{
|
|
36
|
-
"id": "handler/notification_handler/jsonpath_filter.js",
|
|
36
|
+
"id": "@handler/notification_handler/jsonpath_filter.js",
|
|
37
37
|
"anyOf": [
|
|
38
38
|
[
|
|
39
39
|
{ "path": "$.type" , "value": "Announce" } ,
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
]
|
|
42
42
|
]
|
|
43
43
|
} ,
|
|
44
|
-
"handler/notification_handler/valid_eventlog.js",
|
|
45
|
-
"handler/notification_handler/add_timemap_link.js"
|
|
44
|
+
"@handler/notification_handler/valid_eventlog.js",
|
|
45
|
+
"@handler/notification_handler/add_timemap_link.js"
|
|
46
46
|
]
|
|
47
47
|
]
|
|
48
48
|
}
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
"multi": {
|
|
4
4
|
"handlers": [
|
|
5
5
|
[
|
|
6
|
-
"handler/notification_handler/send_notification.js",
|
|
6
|
+
"@handler/notification_handler/send_notification.js",
|
|
7
7
|
{
|
|
8
|
-
"id": "handler/eventlog_notification_handler.js",
|
|
8
|
+
"id": "@handler/eventlog_notification_handler.js",
|
|
9
9
|
"log": "@artifact:strip@.jsonld",
|
|
10
10
|
"dir": "@artifact:strip@"
|
|
11
11
|
}
|
package/lib/handler.js
CHANGED
|
@@ -15,7 +15,15 @@ async function defaultInboxHandler({path,options}) {
|
|
|
15
15
|
|
|
16
16
|
const queue_size = options['queue_size'] ?? 'auto';
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
let worker;
|
|
19
|
+
|
|
20
|
+
if (options['notification_handler']) {
|
|
21
|
+
worker = options['notification_handler']
|
|
22
|
+
.replaceAll(/@handler/g,fsPath.resolve(__dirname,'..','handler'));
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
worker = fsPath.resolve(__dirname,'..','lib','demoNotificationHandler.js');
|
|
26
|
+
}
|
|
19
27
|
|
|
20
28
|
// Run the notifications using a node.js worker pool
|
|
21
29
|
const pool = new piscina({
|
package/lib/index.js
CHANGED
package/lib/util.js
CHANGED
|
@@ -112,6 +112,8 @@ function dynamic_handler(handler,fallback) {
|
|
|
112
112
|
return handler;
|
|
113
113
|
}
|
|
114
114
|
else {
|
|
115
|
+
// translate dynamic path names
|
|
116
|
+
handler = handler.replaceAll(/@handler/g,fsPath.resolve(__dirname,'..','handler'));
|
|
115
117
|
const abs_handler = path.resolve(handler);
|
|
116
118
|
logger.debug(`trying dynamic load of ${handler} -> ${abs_handler}`);
|
|
117
119
|
delete require.cache[abs_handler];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ldn-inbox-server",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.4",
|
|
4
4
|
"description": "A demonstration Event Notifications Inbox server",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"author": "Patrick Hochstenbach <Patrick.Hochstenbach@UGent.be>",
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
"scripts": {
|
|
9
9
|
"server": "npx ldn-inbox-server start-server",
|
|
10
10
|
"demo-post": "curl -X POST -H 'Content-Type: application/ld+json' --data-binary '@examples/offer.jsonld' http://localhost:8000/inbox/",
|
|
11
|
-
"handle-inbox": "npx ldn-inbox-server handler @inbox -hn
|
|
12
|
-
"handle-outbox": "npx ldn-inbox-server handler @outbox -hn
|
|
13
|
-
"handle-eventlog": "npx ldn-inbox-server handler @inbox -hn handler/notification_handler/eventlog.js",
|
|
14
|
-
"handle-inbox-multi": "npx ldn-inbox-server handler @inbox -hn
|
|
15
|
-
"handle-outbox-multi": "npx ldn-inbox-server handler @outbox -hn
|
|
11
|
+
"handle-inbox": "npx ldn-inbox-server handler @inbox -hn @handler/notification_handler/accept.js",
|
|
12
|
+
"handle-outbox": "npx ldn-inbox-server handler @outbox -hn @handler/notification_handler/send_notification.js",
|
|
13
|
+
"handle-eventlog": "npx ldn-inbox-server handler @inbox -hn @handler/notification_handler/eventlog.js",
|
|
14
|
+
"handle-inbox-multi": "npx ldn-inbox-server handler @inbox -hn @handler/notification_handler/multi.js",
|
|
15
|
+
"handle-outbox-multi": "npx ldn-inbox-server handler @outbox -hn @handler/notification_handler/multi.js",
|
|
16
16
|
"clean": "rm -rf error/* inbox/* outbox/* public/events/* public/events/log/* public/artifacts/artifact1 public/artifacts/artifact2 public/artifacts/*.jsonld*"
|
|
17
17
|
},
|
|
18
18
|
"bin": "./bin/ldn-inbox-server.js",
|