@common-stack/server-stack 9.0.2-alpha.10 → 9.0.2-alpha.12
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/lib/express-adapter.cjs +30 -13
- package/lib/express-adapter.cjs.map +1 -1
- package/lib/express-adapter.mjs +30 -13
- package/lib/express-adapter.mjs.map +1 -1
- package/package.json +4 -5
package/lib/express-adapter.cjs
CHANGED
|
@@ -17,26 +17,43 @@
|
|
|
17
17
|
// ─── Engine Detection ────────────────────────────────────────────────────────
|
|
18
18
|
// Read engine choice early (before envalid config is available).
|
|
19
19
|
// This module is loaded at import time, so we read directly from process.env.
|
|
20
|
-
const
|
|
21
|
-
/** Whether the ultimate-express (uWebSockets.js) engine is active */
|
|
22
|
-
const isUltimateEngine = engine === 'ultimate';
|
|
20
|
+
const requestedEngine = (process.env.EXPRESS_ENGINE || 'ultimate').toLowerCase();
|
|
23
21
|
const _require = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('express-adapter.cjs', document.baseURI).href)));
|
|
22
|
+
/**
|
|
23
|
+
* Safely attempt to load the ultimate-* native engine.
|
|
24
|
+
* These packages are declared as `optionalDependencies` and require a recent glibc;
|
|
25
|
+
* in stripped-down container images they may be missing or fail to load — in that
|
|
26
|
+
* case we transparently fall back to classic express + ws.
|
|
27
|
+
*/
|
|
28
|
+
function tryLoadUltimate() {
|
|
29
|
+
try {
|
|
30
|
+
const ultimateExpress = _require('ultimate-express');
|
|
31
|
+
const ultimateWs = _require('ultimate-ws');
|
|
32
|
+
return { express: ultimateExpress, WebSocketServer: ultimateWs.WebSocketServer };
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
if (requestedEngine === 'ultimate') {
|
|
36
|
+
// eslint-disable-next-line no-console
|
|
37
|
+
console.warn('[express-adapter] ultimate-express/ultimate-ws unavailable, falling back to express + ws.', err?.message);
|
|
38
|
+
}
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const ultimate = requestedEngine === 'ultimate' ? tryLoadUltimate() : null;
|
|
43
|
+
/** Whether the ultimate-express (uWebSockets.js) engine is active */
|
|
44
|
+
const isUltimateEngine = ultimate !== null;
|
|
24
45
|
/**
|
|
25
46
|
* The express factory function — creates an Express application.
|
|
26
|
-
* When engine='ultimate', this is ultimate-express (uWS.js-backed).
|
|
27
|
-
*
|
|
47
|
+
* When engine='ultimate' (and the native module loaded), this is ultimate-express (uWS.js-backed).
|
|
48
|
+
* Otherwise this is classic Express 4.
|
|
28
49
|
*/
|
|
29
|
-
const express =
|
|
30
|
-
? _require('ultimate-express')
|
|
31
|
-
: _require('express');
|
|
50
|
+
const express = ultimate ? ultimate.express : _require('express');
|
|
32
51
|
/**
|
|
33
52
|
* WebSocketServer class.
|
|
34
|
-
* When engine='ultimate', this is ultimate-ws (uWS.js-backed).
|
|
35
|
-
*
|
|
53
|
+
* When engine='ultimate' (and the native module loaded), this is ultimate-ws (uWS.js-backed).
|
|
54
|
+
* Otherwise this is the standard `ws` package.
|
|
36
55
|
*/
|
|
37
|
-
const WebSocketServer =
|
|
38
|
-
? _require('ultimate-ws').WebSocketServer
|
|
39
|
-
: _require('ws').WebSocketServer;
|
|
56
|
+
const WebSocketServer = ultimate ? ultimate.WebSocketServer : _require('ws').WebSocketServer;
|
|
40
57
|
/**
|
|
41
58
|
* Create an HTTP server for the given express app.
|
|
42
59
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"express-adapter.cjs","sources":["../src/express-adapter.ts"],"sourcesContent":[null],"names":["createRequire"],"mappings":"gMAAA;;;;;;;;;;;;;;;AAeG;AAQH;AACA;AACA;AACA,MAAM,
|
|
1
|
+
{"version":3,"file":"express-adapter.cjs","sources":["../src/express-adapter.ts"],"sourcesContent":[null],"names":["createRequire"],"mappings":"gMA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AAG,CAAC,CAAC;AAClC,CAAC;AAuBD;;;;;AAKG;AACG,SAAU,UAAU,CAAC,OAAa,EAAA;IACpC,IAAI,gBAAgB,EAAE;AAClB,QAAA,OAAO,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;KAChC;AACD,IAAA,MAAM,UAAU,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAC;AAC3C,IAAA,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACpC,CAAC;AAEK,SAAU,gBAAgB,CAAC,OAAa,EAAA;IAC1C,IAAI,gBAAgB,EAAE;AAClB,QAAA,OAAO,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;KACtC;AACD,IAAA,MAAM,UAAU,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAC;AAC3C,IAAA,OAAO,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;AAC1C"}
|
package/lib/express-adapter.mjs
CHANGED
|
@@ -17,26 +17,43 @@ import {createRequire}from'node:module';/**
|
|
|
17
17
|
// ─── Engine Detection ────────────────────────────────────────────────────────
|
|
18
18
|
// Read engine choice early (before envalid config is available).
|
|
19
19
|
// This module is loaded at import time, so we read directly from process.env.
|
|
20
|
-
const
|
|
21
|
-
/** Whether the ultimate-express (uWebSockets.js) engine is active */
|
|
22
|
-
const isUltimateEngine = engine === 'ultimate';
|
|
20
|
+
const requestedEngine = (process.env.EXPRESS_ENGINE || 'ultimate').toLowerCase();
|
|
23
21
|
const _require = createRequire(import.meta.url);
|
|
22
|
+
/**
|
|
23
|
+
* Safely attempt to load the ultimate-* native engine.
|
|
24
|
+
* These packages are declared as `optionalDependencies` and require a recent glibc;
|
|
25
|
+
* in stripped-down container images they may be missing or fail to load — in that
|
|
26
|
+
* case we transparently fall back to classic express + ws.
|
|
27
|
+
*/
|
|
28
|
+
function tryLoadUltimate() {
|
|
29
|
+
try {
|
|
30
|
+
const ultimateExpress = _require('ultimate-express');
|
|
31
|
+
const ultimateWs = _require('ultimate-ws');
|
|
32
|
+
return { express: ultimateExpress, WebSocketServer: ultimateWs.WebSocketServer };
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
if (requestedEngine === 'ultimate') {
|
|
36
|
+
// eslint-disable-next-line no-console
|
|
37
|
+
console.warn('[express-adapter] ultimate-express/ultimate-ws unavailable, falling back to express + ws.', err?.message);
|
|
38
|
+
}
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const ultimate = requestedEngine === 'ultimate' ? tryLoadUltimate() : null;
|
|
43
|
+
/** Whether the ultimate-express (uWebSockets.js) engine is active */
|
|
44
|
+
const isUltimateEngine = ultimate !== null;
|
|
24
45
|
/**
|
|
25
46
|
* The express factory function — creates an Express application.
|
|
26
|
-
* When engine='ultimate', this is ultimate-express (uWS.js-backed).
|
|
27
|
-
*
|
|
47
|
+
* When engine='ultimate' (and the native module loaded), this is ultimate-express (uWS.js-backed).
|
|
48
|
+
* Otherwise this is classic Express 4.
|
|
28
49
|
*/
|
|
29
|
-
const express =
|
|
30
|
-
? _require('ultimate-express')
|
|
31
|
-
: _require('express');
|
|
50
|
+
const express = ultimate ? ultimate.express : _require('express');
|
|
32
51
|
/**
|
|
33
52
|
* WebSocketServer class.
|
|
34
|
-
* When engine='ultimate', this is ultimate-ws (uWS.js-backed).
|
|
35
|
-
*
|
|
53
|
+
* When engine='ultimate' (and the native module loaded), this is ultimate-ws (uWS.js-backed).
|
|
54
|
+
* Otherwise this is the standard `ws` package.
|
|
36
55
|
*/
|
|
37
|
-
const WebSocketServer =
|
|
38
|
-
? _require('ultimate-ws').WebSocketServer
|
|
39
|
-
: _require('ws').WebSocketServer;
|
|
56
|
+
const WebSocketServer = ultimate ? ultimate.WebSocketServer : _require('ws').WebSocketServer;
|
|
40
57
|
/**
|
|
41
58
|
* Create an HTTP server for the given express app.
|
|
42
59
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"express-adapter.mjs","sources":["../src/express-adapter.ts"],"sourcesContent":[null],"names":[],"mappings":"wCAAA;;;;;;;;;;;;;;;AAeG;AAQH;AACA;AACA;AACA,MAAM,
|
|
1
|
+
{"version":3,"file":"express-adapter.mjs","sources":["../src/express-adapter.ts"],"sourcesContent":[null],"names":[],"mappings":"wCAAA;;;;;;;;;;;;;;;AAeG;AAQH;AACA;AACA;AACA,MAAM,eAAe,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,UAAU,EAAE,WAAW,EAAE,CAAC;AAKjF,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEhD;;;;;AAKG;AACH,SAAS,eAAe,GAAA;AACpB,IAAA,IAAI;AACA,QAAA,MAAM,eAAe,GAAG,QAAQ,CAAC,kBAAkB,CAAC,CAAC;AACrD,QAAA,MAAM,UAAU,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAC;QAC3C,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,UAAU,CAAC,eAAe,EAAE,CAAC;KACpF;IAAC,OAAO,GAAG,EAAE;AACV,QAAA,IAAI,eAAe,KAAK,UAAU,EAAE;;YAEhC,OAAO,CAAC,IAAI,CACR,2FAA2F,EAC1F,GAAa,EAAE,OAAO,CAC1B,CAAC;SACL;AACD,QAAA,OAAO,IAAI,CAAC;KACf;AACL,CAAC;AAED,MAAM,QAAQ,GAAG,eAAe,KAAK,UAAU,GAAG,eAAe,EAAE,GAAG,IAAI,CAAC;AAE3E;AACa,MAAA,gBAAgB,GAAY,QAAQ,KAAK,KAAK;AAE3D;;;;AAIG;AACU,MAAA,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC,OAAO,GAAG,QAAQ,CAAC,SAAS,EAAE;AAIzE;;;;AAIG;MACU,eAAe,GAAG,QAAQ,GAAG,QAAQ,CAAC,eAAe,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,gBAAgB;AAKpG;;;;;AAKG;AACG,SAAU,gBAAgB,CAAC,GAAY,EAAA;IACzC,IAAI,gBAAgB,EAAE;;AAElB,QAAA,OAAO,IAAI,CAAC;KACf;AACD,IAAA,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;AAC9B,IAAA,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;AAClC,CAAC;AAuBD;;;;;AAKG;AACG,SAAU,UAAU,CAAC,OAAa,EAAA;IACpC,IAAI,gBAAgB,EAAE;AAClB,QAAA,OAAO,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;KAChC;AACD,IAAA,MAAM,UAAU,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAC;AAC3C,IAAA,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACpC,CAAC;AAEK,SAAU,gBAAgB,CAAC,OAAa,EAAA;IAC1C,IAAI,gBAAgB,EAAE;AAClB,QAAA,OAAO,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;KACtC;AACD,IAAA,MAAM,UAAU,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAC;AAC3C,IAAA,OAAO,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;AAC1C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@common-stack/server-stack",
|
|
3
|
-
"version": "9.0.2-alpha.
|
|
3
|
+
"version": "9.0.2-alpha.12",
|
|
4
4
|
"description": "common core for higher packages to depend on",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "CDMBase LLC",
|
|
@@ -76,8 +76,6 @@
|
|
|
76
76
|
"reflect-metadata": "^0.1.13",
|
|
77
77
|
"rxjs": "^7.8.1",
|
|
78
78
|
"subscriptions-transport-ws": "^0.11.0",
|
|
79
|
-
"ultimate-express": "^2.0.17",
|
|
80
|
-
"ultimate-ws": "^2.0.8",
|
|
81
79
|
"universal-cookie-express": "^4.0.1",
|
|
82
80
|
"ws": "^8.11.0",
|
|
83
81
|
"xstate": "^5.20.0",
|
|
@@ -93,12 +91,13 @@
|
|
|
93
91
|
"moleculer": "*"
|
|
94
92
|
},
|
|
95
93
|
"optionalDependencies": {
|
|
96
|
-
"ultimate-express": "^2.0.0"
|
|
94
|
+
"ultimate-express": "^2.0.0",
|
|
95
|
+
"ultimate-ws": "^2.0.0"
|
|
97
96
|
},
|
|
98
97
|
"publishConfig": {
|
|
99
98
|
"access": "public"
|
|
100
99
|
},
|
|
101
|
-
"gitHead": "
|
|
100
|
+
"gitHead": "3c7622b4f631a2e2389b3ba41cb238dca684d94a",
|
|
102
101
|
"typescript": {
|
|
103
102
|
"definition": "lib/index.d.ts"
|
|
104
103
|
}
|