ldn-inbox-server 1.6.7 → 1.6.9

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 CHANGED
@@ -201,6 +201,8 @@ Requires configuration properties:
201
201
 
202
202
  A handler to send notification that live in the `@outbox` via the LDN protocol to the LDN `target`.
203
203
 
204
+ If the environoment `DEMO_MODE` is set, no real notifications will be sent.
205
+
204
206
  ### Type handler
205
207
 
206
208
  A handler that accepts any notification with a type that matches one of the `anyOf` types.
@@ -231,7 +233,46 @@ in `public/artifacts-example`. Move this directory tp `public/artifacts` to get
231
233
  - Each artifact requires at least a `.meta` file with the `X-Artifact` header set to `true` to be recognized by the software as an artifact
232
234
  - Each artifact should update the `Link-Template` header in the `.meta` file
233
235
  - The config files in `config/inbox_config.json` and `config/outbox_config.json` define the location of the possible event logs for the artifact
234
-
236
+
237
+ ## API
238
+
239
+ ### getLogger()
240
+
241
+ Returns a LOG4JS logger instance.
242
+
243
+ ### fetchOriginal(url)
244
+
245
+ Resolve the url and return the textual body.
246
+
247
+ ### backOff_fetch(url,options)
248
+
249
+ Return the result of `fetch(url,options)` (tries many times untill the server responds).
250
+
251
+ ### sendNotification(url,payload,options)
252
+
253
+ Send to `url` the payload uptionally a `fetch` can be provided in the options.
254
+
255
+ ### moveTo(oldPath, newPath)
256
+
257
+ Move a file from an oldPath to a newPath .
258
+
259
+ ### parseAsJSON(path)
260
+
261
+ Parse the path into a JSON document (or return null when failed).
262
+
263
+ ### generateId()
264
+
265
+ Generate a uuid URN.
266
+
267
+ ### generatePublished()
268
+
269
+ Generate a ISO8601 date time string.
270
+
271
+ ### parseConfig(path)
272
+
273
+ Parse a path containing `.json` | `.jsonld` | `.json5` | `.yaml` | `.yml` into a
274
+ JavaScript object.
275
+
235
276
  ## See also
236
277
 
237
278
  - [mellon-server](https://www.npmjs.com/package/mellon-server)
@@ -18,7 +18,14 @@ async function handle({path,options,config,notification}) {
18
18
  }
19
19
 
20
20
  logger.info(`Sending ${type} to ${inbox}`);
21
- await sendNotification(inbox, notification);
21
+
22
+ if (process.env.DEMO_MODE) {
23
+ logger.info(`**demo mode** I will not do anything`);
24
+ return { path, options, success: true };
25
+ }
26
+ else {
27
+ await sendNotification(inbox, notification);
28
+ }
22
29
 
23
30
  return { path, options, success: true };
24
31
  }
package/lib/util.js CHANGED
@@ -87,8 +87,8 @@ async function sendNotification(url,json,options) {
87
87
  const response = await fetcher(url, {
88
88
  method: 'POST',
89
89
  headers: {
90
- 'Accept': 'application/json',
91
- 'Content-Type': 'application/json'
90
+ 'Accept': 'application/ld+json',
91
+ 'Content-Type': 'application/ld+json'
92
92
  },
93
93
  body: JSON.stringify(json,null,4)
94
94
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ldn-inbox-server",
3
- "version": "1.6.7",
3
+ "version": "1.6.9",
4
4
  "description": "A demonstration Event Notifications Inbox server",
5
5
  "main": "lib/index.js",
6
6
  "author": "Patrick Hochstenbach <Patrick.Hochstenbach@UGent.be>",