braid-http 1.3.80 → 1.3.81

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
+
@@ -253,11 +253,7 @@ function braidify (req, res, next) {
253
253
  if ((braidify.enable_multiplex ?? true) &&
254
254
  (req.method === 'MULTIPLEX' || req.url.startsWith('/.well-known/multiplexer/'))) {
255
255
 
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", "*")
256
+ free_cors(res)
261
257
  if (req.method === 'OPTIONS') return res.end()
262
258
 
263
259
  // check the multiplexing protocol version
@@ -733,4 +729,14 @@ function ascii_ify(s) {
733
729
  return s.replace(/[^\x20-\x7E]/g, c => '\\u' + c.charCodeAt(0).toString(16).padStart(4, '0'))
734
730
  }
735
731
 
736
- module.exports = braidify
732
+ function free_cors(res) {
733
+ res.setHeader("Access-Control-Allow-Origin", "*")
734
+ res.setHeader("Access-Control-Allow-Methods", "*")
735
+ res.setHeader("Access-Control-Allow-Headers", "*")
736
+ res.setHeader("Access-Control-Expose-Headers", "*")
737
+ }
738
+
739
+ module.exports = {
740
+ braidify,
741
+ free_cors
742
+ }
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.81",
4
4
  "description": "An implementation of Braid-HTTP for Node.js and Browsers",
5
5
  "scripts": {
6
6
  "test": "node test/server.js"