@common-stack/server-stack 9.0.1-alpha.8 → 9.0.2-alpha.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/lib/MainStackServer.cjs +22 -47
- package/lib/MainStackServer.cjs.map +1 -1
- package/lib/MainStackServer.mjs +22 -47
- package/lib/MainStackServer.mjs.map +1 -1
- package/lib/config/env-config.cjs +0 -3
- package/lib/config/env-config.cjs.map +1 -1
- package/lib/config/env-config.mjs +0 -3
- package/lib/config/env-config.mjs.map +1 -1
- package/lib/config/moleculer.config.cjs +7 -1
- package/lib/config/moleculer.config.cjs.map +1 -1
- package/lib/config/moleculer.config.mjs +7 -1
- package/lib/config/moleculer.config.mjs.map +1 -1
- package/lib/connectors/connection-broker.cjs +12 -8
- package/lib/connectors/connection-broker.cjs.map +1 -1
- package/lib/connectors/connection-broker.mjs +12 -8
- package/lib/connectors/connection-broker.mjs.map +1 -1
- package/lib/connectors/mongo-connector.cjs +0 -2
- package/lib/connectors/mongo-connector.cjs.map +1 -1
- package/lib/connectors/mongo-connector.mjs +0 -2
- package/lib/connectors/mongo-connector.mjs.map +1 -1
- package/lib/middleware/services.cjs +46 -11
- package/lib/middleware/services.cjs.map +1 -1
- package/lib/middleware/services.mjs +46 -11
- package/lib/middleware/services.mjs.map +1 -1
- package/lib/servers/ExpressApp.cjs +16 -5
- package/lib/servers/ExpressApp.cjs.map +1 -1
- package/lib/servers/ExpressApp.mjs +15 -4
- package/lib/servers/ExpressApp.mjs.map +1 -1
- package/lib/servers/GraphqlServer.cjs +14 -30
- package/lib/servers/GraphqlServer.cjs.map +1 -1
- package/lib/servers/GraphqlServer.mjs +12 -28
- package/lib/servers/GraphqlServer.mjs.map +1 -1
- package/lib/servers/GraphqlWs.cjs.map +1 -1
- package/lib/servers/GraphqlWs.mjs.map +1 -1
- package/lib/servers/WebsocketMultipathUpdate.cjs +36 -33
- package/lib/servers/WebsocketMultipathUpdate.cjs.map +1 -1
- package/lib/servers/WebsocketMultipathUpdate.mjs +35 -32
- package/lib/servers/WebsocketMultipathUpdate.mjs.map +1 -1
- package/package.json +9 -9
- package/lib/express-adapter.cjs +0 -73
- package/lib/express-adapter.cjs.map +0 -1
- package/lib/express-adapter.mjs +0 -73
- package/lib/express-adapter.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebsocketMultipathUpdate.cjs","sources":["../../src/servers/WebsocketMultipathUpdate.ts"],"sourcesContent":[null],"names":["config","WebSocketServer","useServer","createWebSocketContext"],"mappings":"
|
|
1
|
+
{"version":3,"file":"WebsocketMultipathUpdate.cjs","sources":["../../src/servers/WebsocketMultipathUpdate.ts"],"sourcesContent":[null],"names":["config","WebSocketServer","useServer","createWebSocketContext","url"],"mappings":"+hBAwBa,wBAAwB,CAAA;AAWtB,IAAA,aAAA,CAAA;AACA,IAAA,KAAA,CAAA;IAXH,UAAU,GAAoB,EAAE,CAAC;;AAEjC,IAAA,UAAU,CAAkB;;AAGnB,IAAA,cAAc,CAAS;;AAEvB,IAAA,YAAY,CAAU;AAEvC,IAAA,WAAA,CACW,aAA6B,EAC7B,KAAsC,EAC7C,kBAAyC,EACzC,WAAkC,EAAA;QAH3B,IAAa,CAAA,aAAA,GAAb,aAAa,CAAgB;QAC7B,IAAK,CAAA,KAAA,GAAL,KAAK,CAAiC;;QAK7C,IAAI,CAAC,cAAc,GAAG,WAAW,EAAE,cAAc,IAAIA,gBAAM,CAAC,yBAAyB,CAAC;QACtF,IAAI,CAAC,YAAY,GAAG,WAAW,EAAE,YAAY,IAAIA,gBAAM,CAAC,uBAAuB,CAAC;AAChF,QAAA,IAAI,CAAC,UAAU,GAAG,IAAIC,kBAAe,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,oBAAoB,EAAE,CAAC,CAAC;QACtF,IAAI,CAAC,UAAU,CAAC,oBAAoB,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC;;;AAIxD,QAAAC,cAAS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AE,IAAI,CAAC,cAAc;YACnC,YAAY,EAAE,IAAI,CAAC,YAAY;AAC/B,YAAA,kBAAkB,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,cAAc,IAAI,GAAG,CAAC;SACtE,CAAC;KACL;AAED;;AAEG;IACK,wBAAwB,GAAA;QAC5B,OAAO,IAAI,CAAC,mBAAmB,EAAE,IAAI,IAAI,CAAC,cAAc,CAAC;KAC5D;AAED,IAAA,IAAW,SAAS,GAAA;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC;KAC1B;IACM,KAAK,GAAA;AACR,QAAA,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,UAAU,EAAE;YAC/B,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC;SAChC;KACJ;AACJ"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {WebSocketServer}from'
|
|
1
|
+
import*as url from'url';import {WebSocketServer}from'ws';import {useServer}from'graphql-ws/lib/use/ws';import {createWebSocketContext}from'./websocket-context.mjs';import {config}from'../config/env-config.mjs';class WebsocketMultiPathServer {
|
|
2
2
|
moduleService;
|
|
3
3
|
cache;
|
|
4
|
-
serverHost;
|
|
5
4
|
webSockets = {};
|
|
6
5
|
// private graphqlSubscriptionServer: GraphqlSubscriptionServer;
|
|
7
6
|
_graphqlWs;
|
|
@@ -9,29 +8,13 @@ import {WebSocketServer}from'../express-adapter.mjs';import {useServer}from'grap
|
|
|
9
8
|
maxConnections;
|
|
10
9
|
/** Whether connection limiting is enabled */
|
|
11
10
|
limitEnabled;
|
|
12
|
-
constructor(moduleService, cache,
|
|
13
|
-
multiplePathConfig, limitConfig) {
|
|
11
|
+
constructor(moduleService, cache, multiplePathConfig, limitConfig) {
|
|
14
12
|
this.moduleService = moduleService;
|
|
15
13
|
this.cache = cache;
|
|
16
|
-
this.serverHost = serverHost;
|
|
17
14
|
// Read from validated config (Kubernetes configmap) or use defaults
|
|
18
15
|
this.maxConnections = limitConfig?.maxConnections ?? config.WEBSOCKET_MAX_CONNECTIONS;
|
|
19
16
|
this.limitEnabled = limitConfig?.limitEnabled ?? config.WEBSOCKET_LIMIT_ENABLED;
|
|
20
|
-
|
|
21
|
-
// - ultimate-ws: binds to the ultimate-express app via { server: app, path }
|
|
22
|
-
// - ws: binds to the http.Server via { server: httpServer, path }
|
|
23
|
-
this._graphqlWs = new WebSocketServer({
|
|
24
|
-
server: this.serverHost,
|
|
25
|
-
path: __GRAPHQL_ENDPOINT__,
|
|
26
|
-
verifyClient: (info, cb) => {
|
|
27
|
-
if (this.limitEnabled && this.isConnectionLimitReached()) {
|
|
28
|
-
this.moduleService.logger?.warn?.(`WebSocket connection limit reached (${this.maxConnections}). Rejecting new connection.`);
|
|
29
|
-
cb(false, 503, 'Service Unavailable');
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
cb(true);
|
|
33
|
-
},
|
|
34
|
-
});
|
|
17
|
+
this._graphqlWs = new WebSocketServer({ noServer: true, path: __GRAPHQL_ENDPOINT__ });
|
|
35
18
|
this.webSockets[__GRAPHQL_ENDPOINT__] = this._graphqlWs;
|
|
36
19
|
// Initialize useServer ONCE for the GraphQL WebSocket server
|
|
37
20
|
// This prevents memory leaks from creating new listeners on each connection
|
|
@@ -45,18 +28,7 @@ import {WebSocketServer}from'../express-adapter.mjs';import {useServer}from'grap
|
|
|
45
28
|
continue;
|
|
46
29
|
}
|
|
47
30
|
if (!this.webSockets[key]) {
|
|
48
|
-
this.webSockets[key] = new WebSocketServer({
|
|
49
|
-
server: this.serverHost,
|
|
50
|
-
path: key,
|
|
51
|
-
verifyClient: (info, cb) => {
|
|
52
|
-
if (this.limitEnabled && this.isConnectionLimitReached()) {
|
|
53
|
-
this.moduleService.logger?.warn?.(`WebSocket connection limit reached (${this.maxConnections}). Rejecting new connection.`);
|
|
54
|
-
cb(false, 503, 'Service Unavailable');
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
cb(true);
|
|
58
|
-
},
|
|
59
|
-
});
|
|
31
|
+
this.webSockets[key] = new WebSocketServer({ noServer: true });
|
|
60
32
|
this.webSockets[key].on('connection', (ws, request) => {
|
|
61
33
|
Promise.all([
|
|
62
34
|
moduleService.createContext(request, null),
|
|
@@ -66,6 +38,37 @@ import {WebSocketServer}from'../express-adapter.mjs';import {useServer}from'grap
|
|
|
66
38
|
}
|
|
67
39
|
}
|
|
68
40
|
}
|
|
41
|
+
httpServerUpgrade(httpServer) {
|
|
42
|
+
httpServer.on('upgrade', (request, socket, head) => {
|
|
43
|
+
const pathname = url.parse(request.url).pathname;
|
|
44
|
+
// Check connection limit before accepting new connections
|
|
45
|
+
if (this.limitEnabled && this.isConnectionLimitReached()) {
|
|
46
|
+
this.moduleService.logger?.warn?.(`WebSocket connection limit reached (${this.maxConnections}). Rejecting new connection.`);
|
|
47
|
+
socket.write('HTTP/1.1 503 Service Unavailable\r\n');
|
|
48
|
+
socket.write('Retry-After: 60\r\n');
|
|
49
|
+
socket.write('\r\n');
|
|
50
|
+
socket.destroy();
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (!this.webSockets[pathname]) {
|
|
54
|
+
// in development
|
|
55
|
+
if (pathname !== '/sockjs-node') {
|
|
56
|
+
// need to destroy
|
|
57
|
+
socket.destroy();
|
|
58
|
+
}
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
// code to run when a new connection is made
|
|
62
|
+
this.webSockets[pathname].handleUpgrade(request, socket, head, (ws) => {
|
|
63
|
+
this.webSockets[pathname].emit('connection', ws, request);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
// (new GraphqlWs(this.graphqlWs, this.moduleService, this.cache)).create();
|
|
67
|
+
// useServer({
|
|
68
|
+
// schema: this.moduleService.schema,
|
|
69
|
+
// }, this.graphqlWs);
|
|
70
|
+
return httpServer;
|
|
71
|
+
}
|
|
69
72
|
/**
|
|
70
73
|
* Get total number of active WebSocket connections across all paths
|
|
71
74
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebsocketMultipathUpdate.mjs","sources":["../../src/servers/WebsocketMultipathUpdate.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"WebsocketMultipathUpdate.mjs","sources":["../../src/servers/WebsocketMultipathUpdate.ts"],"sourcesContent":[null],"names":[],"mappings":"wNAwBa,wBAAwB,CAAA;AAWtB,IAAA,aAAA,CAAA;AACA,IAAA,KAAA,CAAA;IAXH,UAAU,GAAoB,EAAE,CAAC;;AAEjC,IAAA,UAAU,CAAkB;;AAGnB,IAAA,cAAc,CAAS;;AAEvB,IAAA,YAAY,CAAU;AAEvC,IAAA,WAAA,CACW,aAA6B,EAC7B,KAAsC,EAC7C,kBAAyC,EACzC,WAAkC,EAAA;QAH3B,IAAa,CAAA,aAAA,GAAb,aAAa,CAAgB;QAC7B,IAAK,CAAA,KAAA,GAAL,KAAK,CAAiC;;QAK7C,IAAI,CAAC,cAAc,GAAG,WAAW,EAAE,cAAc,IAAI,MAAM,CAAC,yBAAyB,CAAC;QACtF,IAAI,CAAC,YAAY,GAAG,WAAW,EAAE,YAAY,IAAI,MAAM,CAAC,uBAAuB,CAAC;AAChF,QAAA,IAAI,CAAC,UAAU,GAAG,IAAI,eAAe,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,oBAAoB,EAAE,CAAC,CAAC;QACtF,IAAI,CAAC,UAAU,CAAC,oBAAoB,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC;;;AAIxD,QAAA,SAAS,CACL;YACI,MAAM,EAAE,aAAa,CAAC,MAAM;;AAE5B,YAAA,OAAO,EAAE,OAAO,GAAG,KAAK,sBAAsB,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,CAAC;AAC5E,SAAA,EACD,IAAI,CAAC,UAAU,CAClB,CAAC;AAEF,QAAA,KAAK,IAAI,GAAG,IAAI,kBAAkB,EAAE;YAChC,IAAI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,IAAI,IAAI,CAAC,cAAc,CAAC;KAC5D;AAED,IAAA,IAAW,SAAS,GAAA;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC;KAC1B;IACM,KAAK,GAAA;AACR,QAAA,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,UAAU,EAAE;YAC/B,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC;SAChC;KACJ;AACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@common-stack/server-stack",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.2-alpha.2",
|
|
4
4
|
"description": "common core for higher packages to depend on",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "CDMBase LLC",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"@cdm-logger/client": "^9.0.17",
|
|
33
33
|
"@cdm-logger/server": "^9.0.17",
|
|
34
34
|
"@cdmbase/graphql-type-uri": "^4.0.0",
|
|
35
|
-
"@common-stack/codegen-zod": "9.0.
|
|
36
|
-
"@common-stack/graphql-api": "9.0.
|
|
37
|
-
"@common-stack/store-redis": "9.0.
|
|
35
|
+
"@common-stack/codegen-zod": "9.0.2-alpha.1",
|
|
36
|
+
"@common-stack/graphql-api": "9.0.2-alpha.2",
|
|
37
|
+
"@common-stack/store-redis": "9.0.2-alpha.1",
|
|
38
38
|
"@graphql-tools/links": "^9.0.1",
|
|
39
39
|
"@graphql-tools/schema": "^10.0.6",
|
|
40
40
|
"@graphql-tools/stitch": "^9.2.10",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"ioredis": "^5.4.1",
|
|
68
68
|
"isomorphic-fetch": "^2.2.1",
|
|
69
69
|
"moleculer": "^0.14.2",
|
|
70
|
-
"mongoose": "^
|
|
70
|
+
"mongoose": "^7.8.9",
|
|
71
71
|
"mongoose-autopopulate": "^1.1.0",
|
|
72
72
|
"mongoose-execution-time": "^1.1.0",
|
|
73
73
|
"morgan": "^1.9.1",
|
|
@@ -84,8 +84,8 @@
|
|
|
84
84
|
"zod": "^4.0.0"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
|
-
"@common-stack/server-core": "9.0.
|
|
88
|
-
"common": "9.0.
|
|
87
|
+
"@common-stack/server-core": "9.0.2-alpha.2",
|
|
88
|
+
"common": "9.0.2-alpha.1"
|
|
89
89
|
},
|
|
90
90
|
"peerDependencies": {
|
|
91
91
|
"@cdm-logger/core": ">=7.0.12",
|
|
@@ -98,8 +98,8 @@
|
|
|
98
98
|
"publishConfig": {
|
|
99
99
|
"access": "public"
|
|
100
100
|
},
|
|
101
|
+
"gitHead": "a9302f283cd6804ea171774a4f476dc911855b42",
|
|
101
102
|
"typescript": {
|
|
102
103
|
"definition": "lib/index.d.ts"
|
|
103
|
-
}
|
|
104
|
-
"gitHead": "295ec131124f14556016989b2012bd7636ef2c04"
|
|
104
|
+
}
|
|
105
105
|
}
|
package/lib/express-adapter.cjs
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var node_module=require('node:module');var_documentCurrentScript=typeofdocument!=='undefined'?document.currentScript:null;/**
|
|
2
|
-
* Express Engine Adapter
|
|
3
|
-
*
|
|
4
|
-
* Provides a unified interface for both Express 4 and ultimate-express (uWebSockets.js).
|
|
5
|
-
* The engine is selected at startup via the `EXPRESS_ENGINE` environment variable:
|
|
6
|
-
*
|
|
7
|
-
* - `EXPRESS_ENGINE=ultimate` (default) — uses ultimate-express + ultimate-ws for best performance
|
|
8
|
-
* - `EXPRESS_ENGINE=express` — uses classic Express 4 + ws for maximum compatibility
|
|
9
|
-
*
|
|
10
|
-
* All server modules import from this adapter instead of directly from 'express' or 'ultimate-express',
|
|
11
|
-
* so switching engines requires zero code changes — just set the env var.
|
|
12
|
-
*
|
|
13
|
-
* IMPORTANT: ultimate-express does NOT support http.createServer(). The server is started via app.listen().
|
|
14
|
-
* Classic express works with both http.createServer() and app.listen().
|
|
15
|
-
* This adapter normalizes both to use app.listen() for consistency.
|
|
16
|
-
*/
|
|
17
|
-
// ─── Engine Detection ────────────────────────────────────────────────────────
|
|
18
|
-
// Read engine choice early (before envalid config is available).
|
|
19
|
-
// This module is loaded at import time, so we read directly from process.env.
|
|
20
|
-
const engine = (process.env.EXPRESS_ENGINE || 'ultimate').toLowerCase();
|
|
21
|
-
/** Whether the ultimate-express (uWebSockets.js) engine is active */
|
|
22
|
-
const isUltimateEngine = engine === 'ultimate';
|
|
23
|
-
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)));
|
|
24
|
-
/**
|
|
25
|
-
* The express factory function — creates an Express application.
|
|
26
|
-
* When engine='ultimate', this is ultimate-express (uWS.js-backed).
|
|
27
|
-
* When engine='express', this is classic Express 4.
|
|
28
|
-
*/
|
|
29
|
-
const express = isUltimateEngine
|
|
30
|
-
? _require('ultimate-express')
|
|
31
|
-
: _require('express');
|
|
32
|
-
/**
|
|
33
|
-
* WebSocketServer class.
|
|
34
|
-
* When engine='ultimate', this is ultimate-ws (uWS.js-backed).
|
|
35
|
-
* When engine='express', this is the standard `ws` package.
|
|
36
|
-
*/
|
|
37
|
-
const WebSocketServer = isUltimateEngine
|
|
38
|
-
? _require('ultimate-ws').WebSocketServer
|
|
39
|
-
: _require('ws').WebSocketServer;
|
|
40
|
-
/**
|
|
41
|
-
* Create an HTTP server for the given express app.
|
|
42
|
-
*
|
|
43
|
-
* - ultimate-express: returns null (uWS manages the server internally via app.listen())
|
|
44
|
-
* - classic express: returns http.createServer(app)
|
|
45
|
-
*/
|
|
46
|
-
function createHttpServer(app) {
|
|
47
|
-
if (isUltimateEngine) {
|
|
48
|
-
// ultimate-express manages its own uWS server; no http.Server is created
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
const http = _require('http');
|
|
52
|
-
return http.createServer(app);
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Body parser middleware.
|
|
56
|
-
*
|
|
57
|
-
* - ultimate-express: uses built-in express.json() / express.urlencoded() for best perf
|
|
58
|
-
* - classic express: uses body-parser package (more battle-tested options)
|
|
59
|
-
*/
|
|
60
|
-
function jsonParser(options) {
|
|
61
|
-
if (isUltimateEngine) {
|
|
62
|
-
return express.json(options);
|
|
63
|
-
}
|
|
64
|
-
const bodyParser = _require('body-parser');
|
|
65
|
-
return bodyParser.json(options);
|
|
66
|
-
}
|
|
67
|
-
function urlencodedParser(options) {
|
|
68
|
-
if (isUltimateEngine) {
|
|
69
|
-
return express.urlencoded(options);
|
|
70
|
-
}
|
|
71
|
-
const bodyParser = _require('body-parser');
|
|
72
|
-
return bodyParser.urlencoded(options);
|
|
73
|
-
}exports.WebSocketServer=WebSocketServer;exports.createHttpServer=createHttpServer;exports.default=express;exports.express=express;exports.isUltimateEngine=isUltimateEngine;exports.jsonParser=jsonParser;exports.urlencodedParser=urlencodedParser;//# sourceMappingURL=express-adapter.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"express-adapter.cjs","sources":["../src/express-adapter.ts"],"sourcesContent":[null],"names":["createRequire"],"mappings":"gMAAA;;;;;;;;;;;;;;;AAeG;AAQH;AACA;AACA;AACA,MAAM,MAAM,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,UAAU,EAAE,WAAW,EAAE,CAAC;AAExE;AACa,MAAA,gBAAgB,GAAY,MAAM,KAAK,WAAW;AAK/D,MAAM,QAAQ,GAAGA,yBAAa,CAAC,qQAAe,CAAC,CAAC;AAEhD;;;;AAIG;AACI,MAAM,OAAO,GAAG,gBAAgB;AACnC,MAAE,QAAQ,CAAC,kBAAkB,CAAC;AAC9B,MAAE,QAAQ,CAAC,SAAS,EAAE;AAI1B;;;;AAIG;AACI,MAAM,eAAe,GAAG,gBAAgB;AAC3C,MAAE,QAAQ,CAAC,aAAa,CAAC,CAAC,eAAe;AACzC,MAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,gBAAgB;AAKrC;;;;;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/lib/express-adapter.mjs
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import {createRequire}from'node:module';/**
|
|
2
|
-
* Express Engine Adapter
|
|
3
|
-
*
|
|
4
|
-
* Provides a unified interface for both Express 4 and ultimate-express (uWebSockets.js).
|
|
5
|
-
* The engine is selected at startup via the `EXPRESS_ENGINE` environment variable:
|
|
6
|
-
*
|
|
7
|
-
* - `EXPRESS_ENGINE=ultimate` (default) — uses ultimate-express + ultimate-ws for best performance
|
|
8
|
-
* - `EXPRESS_ENGINE=express` — uses classic Express 4 + ws for maximum compatibility
|
|
9
|
-
*
|
|
10
|
-
* All server modules import from this adapter instead of directly from 'express' or 'ultimate-express',
|
|
11
|
-
* so switching engines requires zero code changes — just set the env var.
|
|
12
|
-
*
|
|
13
|
-
* IMPORTANT: ultimate-express does NOT support http.createServer(). The server is started via app.listen().
|
|
14
|
-
* Classic express works with both http.createServer() and app.listen().
|
|
15
|
-
* This adapter normalizes both to use app.listen() for consistency.
|
|
16
|
-
*/
|
|
17
|
-
// ─── Engine Detection ────────────────────────────────────────────────────────
|
|
18
|
-
// Read engine choice early (before envalid config is available).
|
|
19
|
-
// This module is loaded at import time, so we read directly from process.env.
|
|
20
|
-
const engine = (process.env.EXPRESS_ENGINE || 'ultimate').toLowerCase();
|
|
21
|
-
/** Whether the ultimate-express (uWebSockets.js) engine is active */
|
|
22
|
-
const isUltimateEngine = engine === 'ultimate';
|
|
23
|
-
const _require = createRequire(import.meta.url);
|
|
24
|
-
/**
|
|
25
|
-
* The express factory function — creates an Express application.
|
|
26
|
-
* When engine='ultimate', this is ultimate-express (uWS.js-backed).
|
|
27
|
-
* When engine='express', this is classic Express 4.
|
|
28
|
-
*/
|
|
29
|
-
const express = isUltimateEngine
|
|
30
|
-
? _require('ultimate-express')
|
|
31
|
-
: _require('express');
|
|
32
|
-
/**
|
|
33
|
-
* WebSocketServer class.
|
|
34
|
-
* When engine='ultimate', this is ultimate-ws (uWS.js-backed).
|
|
35
|
-
* When engine='express', this is the standard `ws` package.
|
|
36
|
-
*/
|
|
37
|
-
const WebSocketServer = isUltimateEngine
|
|
38
|
-
? _require('ultimate-ws').WebSocketServer
|
|
39
|
-
: _require('ws').WebSocketServer;
|
|
40
|
-
/**
|
|
41
|
-
* Create an HTTP server for the given express app.
|
|
42
|
-
*
|
|
43
|
-
* - ultimate-express: returns null (uWS manages the server internally via app.listen())
|
|
44
|
-
* - classic express: returns http.createServer(app)
|
|
45
|
-
*/
|
|
46
|
-
function createHttpServer(app) {
|
|
47
|
-
if (isUltimateEngine) {
|
|
48
|
-
// ultimate-express manages its own uWS server; no http.Server is created
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
const http = _require('http');
|
|
52
|
-
return http.createServer(app);
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Body parser middleware.
|
|
56
|
-
*
|
|
57
|
-
* - ultimate-express: uses built-in express.json() / express.urlencoded() for best perf
|
|
58
|
-
* - classic express: uses body-parser package (more battle-tested options)
|
|
59
|
-
*/
|
|
60
|
-
function jsonParser(options) {
|
|
61
|
-
if (isUltimateEngine) {
|
|
62
|
-
return express.json(options);
|
|
63
|
-
}
|
|
64
|
-
const bodyParser = _require('body-parser');
|
|
65
|
-
return bodyParser.json(options);
|
|
66
|
-
}
|
|
67
|
-
function urlencodedParser(options) {
|
|
68
|
-
if (isUltimateEngine) {
|
|
69
|
-
return express.urlencoded(options);
|
|
70
|
-
}
|
|
71
|
-
const bodyParser = _require('body-parser');
|
|
72
|
-
return bodyParser.urlencoded(options);
|
|
73
|
-
}export{WebSocketServer,createHttpServer,express as default,express,isUltimateEngine,jsonParser,urlencodedParser};//# sourceMappingURL=express-adapter.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"express-adapter.mjs","sources":["../src/express-adapter.ts"],"sourcesContent":[null],"names":[],"mappings":"wCAAA;;;;;;;;;;;;;;;AAeG;AAQH;AACA;AACA;AACA,MAAM,MAAM,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,UAAU,EAAE,WAAW,EAAE,CAAC;AAExE;AACa,MAAA,gBAAgB,GAAY,MAAM,KAAK,WAAW;AAK/D,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEhD;;;;AAIG;AACI,MAAM,OAAO,GAAG,gBAAgB;AACnC,MAAE,QAAQ,CAAC,kBAAkB,CAAC;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