braid-http 1.3.80 → 1.3.82

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
@@ -360,3 +360,26 @@ Configure mutliplexing with:
360
360
  var braidify = require('braid-http').http-server
361
361
  nbraidify.enable_multiplex = true // or false
362
362
  ```
363
+
364
+ ## Test Procedure
365
+
366
+ Using 3 terminals, in first terminal start the demo chat server:
367
+
368
+ ```
369
+ cd demos/chat
370
+ node server.js
371
+ ```
372
+
373
+ in second terminal start the demo blog server:
374
+ ```
375
+ cd demos/blog
376
+ node server.js
377
+ ```
378
+
379
+ and in third and final terminal, start the test server:
380
+ ```
381
+ node test/server.js
382
+ ```
383
+
384
+ now open https://localhost:9000, and make sure all the boxes turn green, and try out the demo chat and blog, sending a message in each.
385
+
@@ -246,6 +246,7 @@ function braidify (req, res, next) {
246
246
  // Define convenience variables
247
247
  req.version = version
248
248
  req.parents = parents
249
+ req.peer = peer
249
250
  req.subscribe = subscribe
250
251
 
251
252
  // Multiplexer stuff
@@ -253,11 +254,7 @@ function braidify (req, res, next) {
253
254
  if ((braidify.enable_multiplex ?? true) &&
254
255
  (req.method === 'MULTIPLEX' || req.url.startsWith('/.well-known/multiplexer/'))) {
255
256
 
256
- // free the cors
257
- res.setHeader("Access-Control-Allow-Origin", "*")
258
- res.setHeader("Access-Control-Allow-Methods", "*")
259
- res.setHeader("Access-Control-Allow-Headers", "*")
260
- res.setHeader("Access-Control-Expose-Headers", "*")
257
+ free_cors(res)
261
258
  if (req.method === 'OPTIONS') return res.end()
262
259
 
263
260
  // check the multiplexing protocol version
@@ -733,4 +730,14 @@ function ascii_ify(s) {
733
730
  return s.replace(/[^\x20-\x7E]/g, c => '\\u' + c.charCodeAt(0).toString(16).padStart(4, '0'))
734
731
  }
735
732
 
736
- module.exports = braidify
733
+ function free_cors(res) {
734
+ res.setHeader("Access-Control-Allow-Origin", "*")
735
+ res.setHeader("Access-Control-Allow-Methods", "*")
736
+ res.setHeader("Access-Control-Allow-Headers", "*")
737
+ res.setHeader("Access-Control-Expose-Headers", "*")
738
+ }
739
+
740
+ module.exports = {
741
+ braidify,
742
+ free_cors
743
+ }
package/index.js CHANGED
@@ -8,5 +8,6 @@ var client = require('./braid-http-client'),
8
8
  module.exports = {
9
9
  fetch: client.fetch,
10
10
  http_client: client.http,
11
- http_server: server
11
+ http_server: server.braidify,
12
+ free_cors: server.free_cors
12
13
  }
package/index.mjs CHANGED
@@ -9,7 +9,8 @@ import braid_server from './braid-http-server.js'
9
9
 
10
10
  var fetch = braid_client.fetch,
11
11
  http_client = braid_client.http,
12
- http_server = braid_server
12
+ http_server = braid_server.braidify,
13
+ free_cors = braid_server.free_cors
13
14
 
14
- export { fetch, http_client, http_server }
15
- export default { fetch, http_client, http_server }
15
+ export { fetch, http_client, http_server, free_cors }
16
+ export default { fetch, http_client, http_server, free_cors }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "braid-http",
3
- "version": "1.3.80",
3
+ "version": "1.3.82",
4
4
  "description": "An implementation of Braid-HTTP for Node.js and Browsers",
5
5
  "scripts": {
6
6
  "test": "node test/server.js"