@es-labs/jslib 0.0.1 → 0.0.2

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/CHANGELOG.md CHANGED
@@ -2,3 +2,6 @@
2
2
 
3
3
  - merging of `@es-labs/node` and `@es-labs/esm` packages
4
4
 
5
+ ### 0.0.2
6
+
7
+ - fix websocket issue
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@es-labs/jslib",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "author": "Aaron Gong",
5
5
  "license": "MIT",
6
6
  "description": "Shareable JS library using ES modules",
package/services/index.js CHANGED
@@ -9,7 +9,7 @@ let servicesConfig = []
9
9
  const services = {}
10
10
 
11
11
  const start = async (
12
- config = JSON.parse(process.env.SERVICES_CONFIG || null) || [], server = null, app = null
12
+ app, server, config = JSON.parse(process.env.SERVICES_CONFIG || null) || []
13
13
  ) => {
14
14
  const serviceTypesAvailable = process.env.SERVICES_TYPES_AVAILABLE.split(',')
15
15
  try {
@@ -92,8 +92,18 @@ export default class Wss {
92
92
  if (!server) this._wss = new WebSocketServer({ port: this._port }) // use seperate port
93
93
  else this._wss = new WebSocketServer({ server })
94
94
  }
95
- if (app) server.on('request', app)
95
+
96
+ // This caused header to fire twice
97
+ // if (app) server.on('request', app)
96
98
 
99
+ // new WebSocketServer({ server }) - no need to handle upgrade event, ws will handle it internally
100
+ // server.on('upgrade', (req, socket, head) => {
101
+ // console.log('WS Upgrade Request Rexeived !!!')
102
+ // this._wss.handleUpgrade(req, socket, head, (ws) => {
103
+ // this._wss.emit('connection', ws, req);
104
+ // });
105
+ // });
106
+
97
107
  console.log('WS API listening on port ' + this._port)
98
108
  if (this._wss) {
99
109
  this._wss.on('connection', (ws) => {