@common-stack/server-stack 8.6.1-alpha.9 → 9.0.1-alpha.1
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 +47 -22
- package/lib/MainStackServer.cjs.map +1 -1
- package/lib/MainStackServer.mjs +47 -22
- package/lib/MainStackServer.mjs.map +1 -1
- package/lib/config/env-config.cjs +3 -0
- package/lib/config/env-config.cjs.map +1 -1
- package/lib/config/env-config.mjs +3 -0
- package/lib/config/env-config.mjs.map +1 -1
- package/lib/express-adapter.cjs +73 -0
- package/lib/express-adapter.cjs.map +1 -0
- package/lib/express-adapter.mjs +73 -0
- package/lib/express-adapter.mjs.map +1 -0
- package/lib/servers/ExpressApp.cjs +4 -4
- package/lib/servers/ExpressApp.cjs.map +1 -1
- package/lib/servers/ExpressApp.mjs +3 -3
- package/lib/servers/ExpressApp.mjs.map +1 -1
- package/lib/servers/GraphqlServer.cjs +30 -14
- package/lib/servers/GraphqlServer.cjs.map +1 -1
- package/lib/servers/GraphqlServer.mjs +28 -12
- 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 +33 -36
- package/lib/servers/WebsocketMultipathUpdate.cjs.map +1 -1
- package/lib/servers/WebsocketMultipathUpdate.mjs +32 -35
- package/lib/servers/WebsocketMultipathUpdate.mjs.map +1 -1
- package/package.json +10 -8
package/lib/MainStackServer.cjs
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
'use strict';require('reflect-metadata');var
|
|
1
|
+
'use strict';require('reflect-metadata');var expressAdapter=require('./express-adapter.cjs'),server=require('@cdm-logger/server'),serverCore=require('@common-stack/server-core'),_=require('lodash-es'),graphqlModule=require('@common-stack/graphql-api/lib/module.js'),ExpressApp=require('./servers/ExpressApp.cjs'),GraphqlServer=require('./servers/GraphqlServer.cjs'),envConfig=require('./config/env-config.cjs'),schemaBuilder=require('./api/schema-builder.cjs'),WebsocketMultipathUpdate=require('./servers/WebsocketMultipathUpdate.cjs'),migrations=require('./utils/migrations.cjs');require('graphql');var subGraphSchemaBuilder=require('./api/sub-graph-schema-builder.cjs'),setup=require('./inngest/setup.cjs');require('inversify'),require('common/server'),require('@common-stack/core');var infrastructureFactory=require('./infrastructure/infrastructure-factory.cjs');require('inngest');/* eslint-disable import/namespace */
|
|
2
2
|
/* eslint-disable import/no-unresolved */
|
|
3
3
|
/* eslint-disable import/no-extraneous-dependencies */
|
|
4
4
|
// version 08/25/2021
|
|
5
5
|
const graphqlApiFeature = graphqlModule.default ?? graphqlModule;
|
|
6
|
-
function startListening(port) {
|
|
7
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
8
|
-
const server = this;
|
|
9
|
-
return new Promise((resolve) => {
|
|
10
|
-
server.listen(port, resolve);
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
6
|
/**
|
|
14
7
|
* Controls the lifecycle of the Application Server
|
|
15
8
|
*
|
|
@@ -17,8 +10,16 @@ function startListening(port) {
|
|
|
17
10
|
* @class StackServer
|
|
18
11
|
*/
|
|
19
12
|
class MainStackServer {
|
|
20
|
-
httpServer;
|
|
21
13
|
app;
|
|
14
|
+
/**
|
|
15
|
+
* The underlying HTTP server.
|
|
16
|
+
* - ultimate-express: null (uWebSockets.js manages the server internally)
|
|
17
|
+
* - classic express: http.Server from http.createServer(app)
|
|
18
|
+
*
|
|
19
|
+
* Also provides backward-compatible startListening() and close() methods.
|
|
20
|
+
*/
|
|
21
|
+
httpServer;
|
|
22
|
+
listenSocket;
|
|
22
23
|
logger;
|
|
23
24
|
infrastructureFactory;
|
|
24
25
|
mainServiceContext;
|
|
@@ -144,28 +145,37 @@ class MainStackServer {
|
|
|
144
145
|
}
|
|
145
146
|
async setupHttpServer() {
|
|
146
147
|
const { context } = this.mainServiceContext;
|
|
147
|
-
// Initialize
|
|
148
|
-
|
|
148
|
+
// Initialize Express app using the configured engine (ultimate-express or classic express)
|
|
149
|
+
// The adapter selects the engine based on EXPRESS_ENGINE env var.
|
|
149
150
|
// Pass Redis client to expressApp so it can be attached at the very top of middleware stack
|
|
150
|
-
this.app = await ExpressApp.expressApp(this.allModules, this.serviceBroker, null,
|
|
151
|
+
this.app = await ExpressApp.expressApp(this.allModules, this.serviceBroker, null, undefined, context.redisClient);
|
|
152
|
+
// Create HTTP server (null for ultimate-express, http.Server for classic express)
|
|
153
|
+
const rawHttpServer = expressAdapter.createHttpServer(this.app);
|
|
154
|
+
// Provide backward-compatible httpServer with startListening() and close()
|
|
155
|
+
this.httpServer = Object.assign(rawHttpServer || {}, {
|
|
156
|
+
startListening: (port) => this.startListening(port),
|
|
157
|
+
close: () => {
|
|
158
|
+
if (rawHttpServer) {
|
|
159
|
+
rawHttpServer.close();
|
|
160
|
+
}
|
|
161
|
+
// ultimate-express handles cleanup internally
|
|
162
|
+
},
|
|
163
|
+
});
|
|
151
164
|
// Register existing express middleware (Redis client middleware is already attached in expressApp)
|
|
152
165
|
this.allModules.registerExpressMiddleware(this.app, this.mainServiceContext.container);
|
|
153
166
|
// Setup Inngest functions
|
|
154
167
|
setup.setupInngestFunctions(this.allModules, this.app, this.mainServiceContext.container, this.logger);
|
|
155
|
-
this.httpServer.startListening = startListening.bind(this.httpServer);
|
|
156
|
-
this.httpServer.on('request', this.app);
|
|
157
|
-
this.httpServer.on('close', () => {
|
|
158
|
-
this.httpServer = undefined;
|
|
159
|
-
});
|
|
160
168
|
// Setup WebSocket if configured
|
|
161
169
|
const customWebsocket = this.allModules.getWebsocketConfig();
|
|
162
170
|
const customWebsocketEnable = !_.isEmpty(customWebsocket);
|
|
163
171
|
if (customWebsocketEnable) {
|
|
164
|
-
this.multiPathWebsocket = new WebsocketMultipathUpdate.WebsocketMultiPathServer(this.serviceBroker, context.redisClient, customWebsocket);
|
|
165
|
-
this.httpServer = this.multiPathWebsocket.httpServerUpgrade(this.httpServer);
|
|
172
|
+
this.multiPathWebsocket = new WebsocketMultipathUpdate.WebsocketMultiPathServer(this.serviceBroker, context.redisClient, expressAdapter.isUltimateEngine ? this.app : rawHttpServer, customWebsocket);
|
|
166
173
|
}
|
|
167
174
|
// Setup GraphQL server
|
|
168
|
-
|
|
175
|
+
// Pass the appropriate server object based on engine:
|
|
176
|
+
// - ultimate-express: pass the app (WebSocket servers bind via { server: app })
|
|
177
|
+
// - classic express: pass the httpServer (WebSocket servers bind via { server: httpServer })
|
|
178
|
+
const graphqlServer = new GraphqlServer.GraphqlServer(this.app, expressAdapter.isUltimateEngine ? this.app : rawHttpServer, context.redisClient, this.serviceBroker, !customWebsocketEnable, this.allModules.apolloCacheKeyGenerator.bind(this.allModules), this.allModules.apolloInvalidateCacheKeyGenerator.bind(this.allModules), this.allModules.graphqlPlugins);
|
|
169
179
|
await graphqlServer.initialize();
|
|
170
180
|
this.app.use('/graphql', (req, res, next) => {
|
|
171
181
|
res.append('Access-Control-Allow-Credentials', JSON.stringify(true));
|
|
@@ -175,6 +185,20 @@ class MainStackServer {
|
|
|
175
185
|
next();
|
|
176
186
|
});
|
|
177
187
|
}
|
|
188
|
+
/**
|
|
189
|
+
* Start listening on the given port.
|
|
190
|
+
* - ultimate-express: uses the built-in high-performance uWebSockets.js server
|
|
191
|
+
* - classic express: uses http.Server.listen()
|
|
192
|
+
*/
|
|
193
|
+
startListening(port) {
|
|
194
|
+
return new Promise((resolve) => {
|
|
195
|
+
const server = expressAdapter.isUltimateEngine ? this.app : this.httpServer;
|
|
196
|
+
server.listen(port, () => {
|
|
197
|
+
this.logger.info('Server listening on port %d (engine: %s)', port, expressAdapter.isUltimateEngine ? 'ultimate-express' : 'express');
|
|
198
|
+
resolve();
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
}
|
|
178
202
|
async start() {
|
|
179
203
|
if (envConfig.config.NODE_ENV === 'development' && this.microserviceContext) {
|
|
180
204
|
await Promise.all([this.mainServiceContext.broker.start(), this.microserviceContext.broker.start()]);
|
|
@@ -200,8 +224,9 @@ class MainStackServer {
|
|
|
200
224
|
if (this.multiPathWebsocket) {
|
|
201
225
|
this.multiPathWebsocket.close();
|
|
202
226
|
}
|
|
203
|
-
if
|
|
204
|
-
|
|
227
|
+
// Close HTTP server if using classic express
|
|
228
|
+
if (this.httpServer && typeof this.httpServer.close === 'function') {
|
|
229
|
+
this.httpServer.close();
|
|
205
230
|
}
|
|
206
231
|
if (this.infrastructureFactory) {
|
|
207
232
|
await this.infrastructureFactory.cleanup();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MainStackServer.cjs","sources":["../src/MainStackServer.ts"],"sourcesContent":[null],"names":["serverLogger","InfrastructureFactory","config","Feature","SubGraphSchemaBuilder","GatewaySchemaBuilder","merge","
|
|
1
|
+
{"version":3,"file":"MainStackServer.cjs","sources":["../src/MainStackServer.ts"],"sourcesContent":[null],"names":["serverLogger","InfrastructureFactory","config","Feature","SubGraphSchemaBuilder","GatewaySchemaBuilder","merge","expressApp","createHttpServer","setupInngestFunctions","isEmpty","WebsocketMultiPathServer","isUltimateEngine","GraphqlServer","migrate"],"mappings":"q3BAAA;AACA;AACA;AACA;AAyBA,MAAM,iBAAiB,GAAI,aAAqB,CAAC,OAAO,IAAI,aAAa,CAAC;AAE1E;;;;;AAKG;MACU,eAAe,CAAA;AACjB,IAAA,GAAG,CAAU;AAEpB;;;;;;AAMG;AACI,IAAA,UAAU,CAAkG;AAE3G,IAAA,YAAY,CAAM;AAElB,IAAA,MAAM,CAAU;AAEhB,IAAA,qBAAqB,CAAwB;AAE7C,IAAA,kBAAkB,CAKxB;AAEM,IAAA,mBAAmB,CAKzB;AAEM,IAAA,kBAAkB,CAA2B;AAE7C,IAAA,aAAa,CAAgB;AAE7B,IAAA,QAAQ,CAAC;AAET,IAAA,OAAO,CAA0B;AAEjC,IAAA,aAAa,CAAiB;AAE9B,IAAA,UAAU,CAAU;AAE5B,IAAA,WAAA,CAAY,OAAsB,EAA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,EAAE,CAAC;SAC3B;AACD,QAAA,IAAI,IAAI,CAAC,qBAAqB,EAAE;AAC5B,YAAA,MAAM,IAAI,CAAC,qBAAqB,CAAC,OAAO,EAAE,CAAC;SAC9C;AACD,QAAA,IAAI,IAAI,CAAC,kBAAkB,EAAE,MAAM,EAAE;YACjC,MAAM,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;SAC/C;AACD,QAAA,IAAI,IAAI,CAAC,mBAAmB,EAAE,MAAM,EAAE;YAClC,MAAM,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;SAChD;KACJ;AACJ"}
|
package/lib/MainStackServer.mjs
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
import'reflect-metadata';import
|
|
1
|
+
import'reflect-metadata';import {createHttpServer,isUltimateEngine}from'./express-adapter.mjs';import {logger}from'@cdm-logger/server';import {Feature}from'@common-stack/server-core';import {isEmpty,merge}from'lodash-es';import graphqlModule from'@common-stack/graphql-api/lib/module.js';import {expressApp}from'./servers/ExpressApp.mjs';import {GraphqlServer}from'./servers/GraphqlServer.mjs';import {config}from'./config/env-config.mjs';import {GatewaySchemaBuilder}from'./api/schema-builder.mjs';import {WebsocketMultiPathServer}from'./servers/WebsocketMultipathUpdate.mjs';import {migrate}from'./utils/migrations.mjs';import'graphql';import {SubGraphSchemaBuilder}from'./api/sub-graph-schema-builder.mjs';import {setupInngestFunctions}from'./inngest/setup.mjs';import'inversify';import'common/server';import'@common-stack/core';import {InfrastructureFactory}from'./infrastructure/infrastructure-factory.mjs';import'inngest';/* eslint-disable import/namespace */
|
|
2
2
|
/* eslint-disable import/no-unresolved */
|
|
3
3
|
/* eslint-disable import/no-extraneous-dependencies */
|
|
4
4
|
// version 08/25/2021
|
|
5
5
|
const graphqlApiFeature = graphqlModule.default ?? graphqlModule;
|
|
6
|
-
function startListening(port) {
|
|
7
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
8
|
-
const server = this;
|
|
9
|
-
return new Promise((resolve) => {
|
|
10
|
-
server.listen(port, resolve);
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
6
|
/**
|
|
14
7
|
* Controls the lifecycle of the Application Server
|
|
15
8
|
*
|
|
@@ -17,8 +10,16 @@ function startListening(port) {
|
|
|
17
10
|
* @class StackServer
|
|
18
11
|
*/
|
|
19
12
|
class MainStackServer {
|
|
20
|
-
httpServer;
|
|
21
13
|
app;
|
|
14
|
+
/**
|
|
15
|
+
* The underlying HTTP server.
|
|
16
|
+
* - ultimate-express: null (uWebSockets.js manages the server internally)
|
|
17
|
+
* - classic express: http.Server from http.createServer(app)
|
|
18
|
+
*
|
|
19
|
+
* Also provides backward-compatible startListening() and close() methods.
|
|
20
|
+
*/
|
|
21
|
+
httpServer;
|
|
22
|
+
listenSocket;
|
|
22
23
|
logger;
|
|
23
24
|
infrastructureFactory;
|
|
24
25
|
mainServiceContext;
|
|
@@ -144,28 +145,37 @@ class MainStackServer {
|
|
|
144
145
|
}
|
|
145
146
|
async setupHttpServer() {
|
|
146
147
|
const { context } = this.mainServiceContext;
|
|
147
|
-
// Initialize
|
|
148
|
-
|
|
148
|
+
// Initialize Express app using the configured engine (ultimate-express or classic express)
|
|
149
|
+
// The adapter selects the engine based on EXPRESS_ENGINE env var.
|
|
149
150
|
// Pass Redis client to expressApp so it can be attached at the very top of middleware stack
|
|
150
|
-
this.app = await expressApp(this.allModules, this.serviceBroker, null,
|
|
151
|
+
this.app = await expressApp(this.allModules, this.serviceBroker, null, undefined, context.redisClient);
|
|
152
|
+
// Create HTTP server (null for ultimate-express, http.Server for classic express)
|
|
153
|
+
const rawHttpServer = createHttpServer(this.app);
|
|
154
|
+
// Provide backward-compatible httpServer with startListening() and close()
|
|
155
|
+
this.httpServer = Object.assign(rawHttpServer || {}, {
|
|
156
|
+
startListening: (port) => this.startListening(port),
|
|
157
|
+
close: () => {
|
|
158
|
+
if (rawHttpServer) {
|
|
159
|
+
rawHttpServer.close();
|
|
160
|
+
}
|
|
161
|
+
// ultimate-express handles cleanup internally
|
|
162
|
+
},
|
|
163
|
+
});
|
|
151
164
|
// Register existing express middleware (Redis client middleware is already attached in expressApp)
|
|
152
165
|
this.allModules.registerExpressMiddleware(this.app, this.mainServiceContext.container);
|
|
153
166
|
// Setup Inngest functions
|
|
154
167
|
setupInngestFunctions(this.allModules, this.app, this.mainServiceContext.container, this.logger);
|
|
155
|
-
this.httpServer.startListening = startListening.bind(this.httpServer);
|
|
156
|
-
this.httpServer.on('request', this.app);
|
|
157
|
-
this.httpServer.on('close', () => {
|
|
158
|
-
this.httpServer = undefined;
|
|
159
|
-
});
|
|
160
168
|
// Setup WebSocket if configured
|
|
161
169
|
const customWebsocket = this.allModules.getWebsocketConfig();
|
|
162
170
|
const customWebsocketEnable = !isEmpty(customWebsocket);
|
|
163
171
|
if (customWebsocketEnable) {
|
|
164
|
-
this.multiPathWebsocket = new WebsocketMultiPathServer(this.serviceBroker, context.redisClient, customWebsocket);
|
|
165
|
-
this.httpServer = this.multiPathWebsocket.httpServerUpgrade(this.httpServer);
|
|
172
|
+
this.multiPathWebsocket = new WebsocketMultiPathServer(this.serviceBroker, context.redisClient, isUltimateEngine ? this.app : rawHttpServer, customWebsocket);
|
|
166
173
|
}
|
|
167
174
|
// Setup GraphQL server
|
|
168
|
-
|
|
175
|
+
// Pass the appropriate server object based on engine:
|
|
176
|
+
// - ultimate-express: pass the app (WebSocket servers bind via { server: app })
|
|
177
|
+
// - classic express: pass the httpServer (WebSocket servers bind via { server: httpServer })
|
|
178
|
+
const graphqlServer = new GraphqlServer(this.app, isUltimateEngine ? this.app : rawHttpServer, context.redisClient, this.serviceBroker, !customWebsocketEnable, this.allModules.apolloCacheKeyGenerator.bind(this.allModules), this.allModules.apolloInvalidateCacheKeyGenerator.bind(this.allModules), this.allModules.graphqlPlugins);
|
|
169
179
|
await graphqlServer.initialize();
|
|
170
180
|
this.app.use('/graphql', (req, res, next) => {
|
|
171
181
|
res.append('Access-Control-Allow-Credentials', JSON.stringify(true));
|
|
@@ -175,6 +185,20 @@ class MainStackServer {
|
|
|
175
185
|
next();
|
|
176
186
|
});
|
|
177
187
|
}
|
|
188
|
+
/**
|
|
189
|
+
* Start listening on the given port.
|
|
190
|
+
* - ultimate-express: uses the built-in high-performance uWebSockets.js server
|
|
191
|
+
* - classic express: uses http.Server.listen()
|
|
192
|
+
*/
|
|
193
|
+
startListening(port) {
|
|
194
|
+
return new Promise((resolve) => {
|
|
195
|
+
const server = isUltimateEngine ? this.app : this.httpServer;
|
|
196
|
+
server.listen(port, () => {
|
|
197
|
+
this.logger.info('Server listening on port %d (engine: %s)', port, isUltimateEngine ? 'ultimate-express' : 'express');
|
|
198
|
+
resolve();
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
}
|
|
178
202
|
async start() {
|
|
179
203
|
if (config.NODE_ENV === 'development' && this.microserviceContext) {
|
|
180
204
|
await Promise.all([this.mainServiceContext.broker.start(), this.microserviceContext.broker.start()]);
|
|
@@ -200,8 +224,9 @@ class MainStackServer {
|
|
|
200
224
|
if (this.multiPathWebsocket) {
|
|
201
225
|
this.multiPathWebsocket.close();
|
|
202
226
|
}
|
|
203
|
-
if
|
|
204
|
-
|
|
227
|
+
// Close HTTP server if using classic express
|
|
228
|
+
if (this.httpServer && typeof this.httpServer.close === 'function') {
|
|
229
|
+
this.httpServer.close();
|
|
205
230
|
}
|
|
206
231
|
if (this.infrastructureFactory) {
|
|
207
232
|
await this.infrastructureFactory.cleanup();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MainStackServer.mjs","sources":["../src/MainStackServer.ts"],"sourcesContent":[null],"names":["serverLogger"],"mappings":"
|
|
1
|
+
{"version":3,"file":"MainStackServer.mjs","sources":["../src/MainStackServer.ts"],"sourcesContent":[null],"names":["serverLogger"],"mappings":"g6BAAA;AACA;AACA;AACA;AAyBA,MAAM,iBAAiB,GAAI,aAAqB,CAAC,OAAO,IAAI,aAAa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eAAe,CAAC,CAAC;SACrC;QAAC,OAAO,CAAC,EAAE;YACR,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAU,EAAE,gCAAgC,CAAC,CAAC;SACnE;KACJ;AAEM,IAAA,MAAM,OAAO,GAAA;AAChB,QAAA,IAAI,IAAI,CAAC,kBAAkB,EAAE;AACzB,YAAA,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,CAAC;SACnC;;AAED,QAAA,IAAI,IAAI,CAAC,UAAU,IAAI,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,KAAK,UAAU,EAAE;AAChE,YAAA,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;SAC3B;AACD,QAAA,IAAI,IAAI,CAAC,qBAAqB,EAAE;AAC5B,YAAA,MAAM,IAAI,CAAC,qBAAqB,CAAC,OAAO,EAAE,CAAC;SAC9C;AACD,QAAA,IAAI,IAAI,CAAC,kBAAkB,EAAE,MAAM,EAAE;YACjC,MAAM,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;SAC/C;AACD,QAAA,IAAI,IAAI,CAAC,mBAAmB,EAAE,MAAM,EAAE;YAClC,MAAM,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;SAChD;KACJ;AACJ"}
|
|
@@ -46,6 +46,9 @@ const config = envalid__namespace.cleanEnv(process.env,
|
|
|
46
46
|
INNGEST_CLIENT_ID: str({ devDefault: '', default: '' }),
|
|
47
47
|
// Stable application ID used for Inngest client registration across deployments
|
|
48
48
|
APPLICATION_ID: str({ devDefault: '', default: '' }),
|
|
49
|
+
// HTTP server engine: 'ultimate' (uWebSockets.js, faster) or 'express' (classic Node.js http)
|
|
50
|
+
// ultimate-express is a drop-in replacement but requires app.listen() instead of http.createServer()
|
|
51
|
+
EXPRESS_ENGINE: str({ default: 'ultimate', choices: ['ultimate', 'express'], devDefault: 'ultimate' }),
|
|
49
52
|
// WebSocket connection limits per pod instance
|
|
50
53
|
// Recommended: ~20000 per 1Gi memory
|
|
51
54
|
WEBSOCKET_MAX_CONNECTIONS: num({ default: 20000, devDefault: 10000 }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env-config.cjs","sources":["../../src/config/env-config.ts"],"sourcesContent":[null],"names":["envalid"],"mappings":"gZAEA,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,GAAGA,kBAAO,CAAC;AAE5B,MAAA,MAAM,GAAGA,kBAAO,CAAC,QAAQ,CAClC,OAAO,CAAC,GAAG;AACX;AACA;IACI,QAAQ,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,CAAC,EAAE,CAAC;IACnG,QAAQ,EAAE,GAAG,EAAE;IACf,SAAS,EAAE,GAAG,EAAE;IAChB,OAAO,EAAE,GAAG,EAAE;IACd,gBAAgB,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;IAC9C,WAAW,EAAE,GAAG,EAAE;IAClB,WAAW,EAAE,GAAG,EAAE;IAClB,UAAU,EAAE,GAAG,EAAE;IACjB,SAAS,EAAE,GAAG,EAAE;IAChB,QAAQ,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;IACrC,iBAAiB,EAAE,IAAI,CAAC;AACpB,QAAA,UAAU,EAAE,oCAAoC;AAChD,QAAA,OAAO,EAAE,oCAAoC;KAChD,CAAC;IACF,SAAS,EAAE,GAAG,CAAC,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC;IAC3C,qBAAqB,EAAE,IAAI,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;IAClD,sBAAsB,EAAE,IAAI,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;IAClD,aAAa,EAAE,GAAG,CAAC,EAAE,UAAU,EAAE,eAAe,EAA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IpD,cAAc,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,UAAU,EAAE,SAAS,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC;;;AAItG,IAAA,yBAAyB,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;AACrE,IAAA,uBAAuB,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;CACtE"}
|
|
@@ -46,6 +46,9 @@ const config = envalid.cleanEnv(process.env,
|
|
|
46
46
|
INNGEST_CLIENT_ID: str({ devDefault: '', default: '' }),
|
|
47
47
|
// Stable application ID used for Inngest client registration across deployments
|
|
48
48
|
APPLICATION_ID: str({ devDefault: '', default: '' }),
|
|
49
|
+
// HTTP server engine: 'ultimate' (uWebSockets.js, faster) or 'express' (classic Node.js http)
|
|
50
|
+
// ultimate-express is a drop-in replacement but requires app.listen() instead of http.createServer()
|
|
51
|
+
EXPRESS_ENGINE: str({ default: 'ultimate', choices: ['ultimate', 'express'], devDefault: 'ultimate' }),
|
|
49
52
|
// WebSocket connection limits per pod instance
|
|
50
53
|
// Recommended: ~20000 per 1Gi memory
|
|
51
54
|
WEBSOCKET_MAX_CONNECTIONS: num({ default: 20000, devDefault: 10000 }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env-config.mjs","sources":["../../src/config/env-config.ts"],"sourcesContent":[null],"names":[],"mappings":"gCAEA,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;AAE5B,MAAA,MAAM,GAAG,OAAO,CAAC,QAAQ,CAClC,OAAO,CAAC,GAAG;AACX;AACA;IACI,QAAQ,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,YAAY,EAAE,SAAS,EAAE,aAAa,EA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AE,IAAI;AACV,YAAA,IAAI,EAAE,UAAU;SACnB,CAAC;AACF,QAAA,OAAO,EAAE,gDAAgD;KAC5D,CAAC;IACF,iBAAiB,EAAE,GAAG,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC;IAC/C,mBAAmB,EAAE,GAAG,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC;AACjD,IAAA,cAAc,EAAE,IAAI,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAC1D,IAAA,mBAAmB,EAAE,GAAG,CAAC,EAAE,UAAU,EAAE,aAAa,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;AAC9E,IAAA,gBAAgB,EAAE,GAAG,CAAC,EAAE,UAAU,EAAE,uBAAuB,EAAE,OAAO,EAAE,yBAAyB,EAAE,CAAC;AAClG,IAAA,iBAAiB,EAAE,GAAG,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;AAEvD,IAAA,cAAc,EAAE,GAAG,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;;IAIpD,cAAc,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,UAAU,EAAE,SAAS,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC;;;AAItG,IAAA,yBAAyB,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;AACrE,IAAA,uBAAuB,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;CACtE"}
|
|
@@ -0,0 +1,73 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"express-adapter.cjs","sources":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;KACtC;AACD,IAAA,MAAM,UAAU,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAC;AAC3C,IAAA,OAAO,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;AAC1C"}
|
|
@@ -0,0 +1,73 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"express-adap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U,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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var expressAdapter=require('../express-adapter.cjs'),error=require('../middleware/error.cjs'),services=require('../middleware/services.cjs'),sentry=require('../middleware/sentry.cjs'),redisClient=require('../middleware/redis-client.cjs'),cors=require('../middleware/cors.cjs');/* eslint-disable @typescript-eslint/no-var-requires */
|
|
2
2
|
function expressApp(modules, options, middlewares, http, redisClient$1) {
|
|
3
|
-
const app = express();
|
|
3
|
+
const app = expressAdapter.express();
|
|
4
4
|
// FIRST PRIORITY: Add Redis client middleware at the very top
|
|
5
5
|
// This ensures req.redisClient is available to ALL downstream middleware
|
|
6
6
|
if (redisClient$1) {
|
|
@@ -23,14 +23,14 @@ function expressApp(modules, options, middlewares, http, redisClient$1) {
|
|
|
23
23
|
res.header('Access-Control-Allow-Headers', 'X-Requested-With, X-HTTP-Method-Override, X-CSP-Nonce, Content-Type, Accept');
|
|
24
24
|
next();
|
|
25
25
|
});
|
|
26
|
-
app.use(
|
|
26
|
+
app.use(expressAdapter.jsonParser({
|
|
27
27
|
limit: '50mb',
|
|
28
28
|
verify: (req, res, buf) => {
|
|
29
29
|
// #Todo: Find some proper solution for it
|
|
30
30
|
req.rawBody = buf;
|
|
31
31
|
},
|
|
32
32
|
}));
|
|
33
|
-
app.use(
|
|
33
|
+
app.use(expressAdapter.urlencodedParser({ limit: '50mb', extended: true, parameterLimit: 50000 }));
|
|
34
34
|
for (const applyMiddleware of modules.middlewares) {
|
|
35
35
|
applyMiddleware(app);
|
|
36
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpressApp.cjs","sources":["../../src/servers/ExpressApp.ts"],"sourcesContent":[null],"names":["redisClient","redisClientMiddleware","contextServicesMiddleware","sentryMiddleware","corsMiddleware","errorMiddleware","sentryErrorHandlerMiddleware"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ExpressApp.cjs","sources":["../../src/servers/ExpressApp.ts"],"sourcesContent":[null],"names":["redisClient","express","redisClientMiddleware","contextServicesMiddleware","sentryMiddleware","corsMiddleware","jsonParser","urlencodedParser","errorMiddleware","sentryErrorHandlerMiddleware"],"mappings":"kSAAA;AAUM,SAAU,UAAU,CAAC,OAAgB,EAAE,OAAuB,EAAE,WAAW,EAAE,IAAK,EAAEA,aAAY,EAAA;AAClG,IAAA,MAAM,GAAG,GAAGC,sBAAO,EAAE,CAAC;;;IAItB,IAAID,aAAW,EAAE;QACb,GAAG,CAAC,GAAG,CAACE,iCAAqB,CAACF,aAAW,CAAC,CAAC,CAAC;KAC/C;AAED,IAAA,GAAG,CAAC,GAAG,CAACG,kCAAyB,CAAC,OAAO,CAAC,aAAa,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC;AAClF,IAAA,KAAK,MAAM,eAAe,IAAI,OAAO,CAAC,WAAW,EAAE;QAC/C,eAAe,CAAC,GAAG,CAAC,CAAC;KACxB;;AAGD,IAAA,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;AAE1B,IAAA,GAAG,CAAC,GAAG,CAACC,uBAAgB,CAAC,CAAC;AAE1B,IAAA,IAAI,WAAW,KAAK,IAAI,EAAE;AACtB,QAAA,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;KACxB;AAED,IAAA,GAAG,CAAC,GAAG,CAACC,mBAAc,CAAC,CAAC;IACxB,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,KAAI;AACvB,QAAA,GAAG,CAAC,MAAM,CAAC,kCAAkC,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;AACrE,QAAA,GAAG,CAAC,MAAM,CAAC,8BAA8B,EAAE,qBAAqB,CAAC,CAAC;AAClE,QAAA,GAAG,CAAC,MAAM,CACN,8BAA8B,EAC9B,6EAA6E,CAChF,CAAC;AACF,QAAA,IAAI,EAAE,CAAC;AACX,KAAC,CAAC,CAAC;AAEH,IAAA,GAAG,CAAC,GAAG,CACHC,yBAAU,CAAC;AACP,QAAA,KAAK,EAAE,MAAM;QACb,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,KAAI;;AAErB,YAAA,GAAW,CAAC,OAAO,GAAG,GAAG,CAAC;SAC9B;AACJ,KAAA,CAAC,CACL,CAAC;IACF,GAAG,CAAC,GAAG,CAACC,+BAAgB,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;AAEpF,IAAA,KAAK,MAAM,eAAe,IAAI,OAAO,CAAC,WAAW,EAAE;QAC/C,eAAe,CAAC,GAAG,CAAC,CAAC;KACxB;IAED,IAAI,OAAO,EAAE;AACT,QAAA,GAAG,CAAC,GAAG,CAACC,qBAAe,CAAC,CAAC;KAC5B;AAED,IAAA,GAAG,CAAC,GAAG,CAACC,mCAA4B,CAAC,CAAC;AAEtC,IAAA,OAAO,GAAG,CAAC;AACf"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import express
|
|
1
|
+
import {express,jsonParser,urlencodedParser}from'../express-adapter.mjs';import {errorMiddleware}from'../middleware/error.mjs';import {contextServicesMiddleware}from'../middleware/services.mjs';import {sentryMiddleware,sentryErrorHandlerMiddleware}from'../middleware/sentry.mjs';import {redisClientMiddleware}from'../middleware/redis-client.mjs';import {corsMiddleware}from'../middleware/cors.mjs';/* eslint-disable @typescript-eslint/no-var-requires */
|
|
2
2
|
function expressApp(modules, options, middlewares, http, redisClient) {
|
|
3
3
|
const app = express();
|
|
4
4
|
// FIRST PRIORITY: Add Redis client middleware at the very top
|
|
@@ -23,14 +23,14 @@ function expressApp(modules, options, middlewares, http, redisClient) {
|
|
|
23
23
|
res.header('Access-Control-Allow-Headers', 'X-Requested-With, X-HTTP-Method-Override, X-CSP-Nonce, Content-Type, Accept');
|
|
24
24
|
next();
|
|
25
25
|
});
|
|
26
|
-
app.use(
|
|
26
|
+
app.use(jsonParser({
|
|
27
27
|
limit: '50mb',
|
|
28
28
|
verify: (req, res, buf) => {
|
|
29
29
|
// #Todo: Find some proper solution for it
|
|
30
30
|
req.rawBody = buf;
|
|
31
31
|
},
|
|
32
32
|
}));
|
|
33
|
-
app.use(
|
|
33
|
+
app.use(urlencodedParser({ limit: '50mb', extended: true, parameterLimit: 50000 }));
|
|
34
34
|
for (const applyMiddleware of modules.middlewares) {
|
|
35
35
|
applyMiddleware(app);
|
|
36
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpressApp.mjs","sources":["../../src/servers/ExpressApp.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ExpressApp.mjs","sources":["../../src/servers/ExpressApp.ts"],"sourcesContent":[null],"names":[],"mappings":"8YAAA;AAUM,SAAU,UAAU,CAAC,OAAgB,EAAE,OAAuB,EAAE,WAAW,EAAE,IAAK,EAAE,WAAY,EAAA;AAClG,IAAA,MAAM,GAAG,GAAG,OAAO,EAAE,CAAC;;;IAItB,IAAI,WAAW,EAAE;QACb,GAAG,CAAC,GAAG,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC,CAAC;KAC/C;AAED,IAAA,GAAG,CAAC,GAAG,CAAC,yBAAyB,CAAC,OAAO,CAAC,aAAa,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC;AAClF,IAAA,KAAK,MAAM,eAAe,IAAI,OAAO,CAAC,WAAW,EAAE;QAC/C,eAAe,CAAC,GAAG,CAAC,CAAC;KACxB;;AAGD,IAAA,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;AAE1B,IAAA,GAAG,CAAC,GAAG,CAAC,gBAAgB,CAAC,C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require('@apollo/server/express4'),cacheControl=require('@apollo/server/plugin/cacheControl')
|
|
1
|
+
'use strict';var server=require('@apollo/server'),express4=require('@apollo/server/express4'),cacheControl=require('@apollo/server/plugin/cacheControl');require('isomorphic-fetch');var expressAdapter=require('../express-adapter.cjs'),cors=require('cors'),Keyv=require('keyv'),KeyvRedis=require('@keyv/redis'),utils_keyvadapter=require('@apollo/utils.keyvadapter'),storeRedis=require('@common-stack/store-redis'),GraphqlWs=require('./GraphqlWs.cjs'),envConfig=require('../config/env-config.cjs');if ((process.env.LOG_LEVEL && process.env.LOG_LEVEL === 'trace') || process.env.LOG_LEVEL === 'debug') ;
|
|
2
2
|
// @workaround as the `dataSources` not available in Subscription (websocket) Context.
|
|
3
3
|
// https://github.com/apollographql/apollo-server/issues/1526 need to revisit in Apollo-Server v3.
|
|
4
4
|
const constructDataSourcesForSubscriptions = (context, cache, dataSources) => {
|
|
@@ -12,7 +12,7 @@ const constructDataSourcesForSubscriptions = (context, cache, dataSources) => {
|
|
|
12
12
|
};
|
|
13
13
|
class GraphqlServer {
|
|
14
14
|
app;
|
|
15
|
-
|
|
15
|
+
wsServerHost;
|
|
16
16
|
redisClient;
|
|
17
17
|
moduleService;
|
|
18
18
|
enableSubscription;
|
|
@@ -21,9 +21,10 @@ class GraphqlServer {
|
|
|
21
21
|
plugins;
|
|
22
22
|
logger;
|
|
23
23
|
graphqlWsServer;
|
|
24
|
-
constructor(app,
|
|
24
|
+
constructor(app, wsServerHost, // ultimate-express app or http.Server
|
|
25
|
+
redisClient, moduleService, enableSubscription = true, cacheKeyGenerator, invalidateCacheKeyGenerator, plugins) {
|
|
25
26
|
this.app = app;
|
|
26
|
-
this.
|
|
27
|
+
this.wsServerHost = wsServerHost;
|
|
27
28
|
this.redisClient = redisClient;
|
|
28
29
|
this.moduleService = moduleService;
|
|
29
30
|
this.enableSubscription = enableSubscription;
|
|
@@ -32,8 +33,11 @@ class GraphqlServer {
|
|
|
32
33
|
this.plugins = plugins;
|
|
33
34
|
this.logger = this.moduleService.logger.child({ className: 'GraphqlServer' });
|
|
34
35
|
if (enableSubscription) {
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
// WebSocketServer binds to different hosts depending on engine:
|
|
37
|
+
// - ultimate-express: pass the app as 'server' (ultimate-ws)
|
|
38
|
+
// - classic express: pass the httpServer as 'server' (ws)
|
|
39
|
+
const wsServer = new expressAdapter.WebSocketServer({
|
|
40
|
+
server: this.wsServerHost,
|
|
37
41
|
path: envConfig.config.GRAPHQL_ENDPOINT,
|
|
38
42
|
});
|
|
39
43
|
this.graphqlWsServer = new GraphqlWs.GraphqlWs(wsServer, this.moduleService, this.redisClient);
|
|
@@ -50,7 +54,7 @@ class GraphqlServer {
|
|
|
50
54
|
origin: [envConfig.config.CLIENT_URL],
|
|
51
55
|
credentials: true,
|
|
52
56
|
};
|
|
53
|
-
this.app.use(__GRAPHQL_ENDPOINT__, cors(corsOptions), express.json(), express4.expressMiddleware(apolloServer, {
|
|
57
|
+
this.app.use(__GRAPHQL_ENDPOINT__, cors(corsOptions), expressAdapter.express.json(), express4.expressMiddleware(apolloServer, {
|
|
54
58
|
context: async ({ req, res, connection }) => {
|
|
55
59
|
let context;
|
|
56
60
|
let addons = {};
|
|
@@ -117,17 +121,29 @@ class GraphqlServer {
|
|
|
117
121
|
const cacheSet = cacheAdapter.set.bind(cacheAdapter);
|
|
118
122
|
cacheAdapter.set = (key, value, opts) => cacheSet(key.replaceAll('fqc:', ''), value, opts);
|
|
119
123
|
const { cacheKeyGenerator, invalidateCacheKeyGenerator, logger } = this;
|
|
124
|
+
const serverPlugins = [
|
|
125
|
+
cacheControl.ApolloServerPluginCacheControl(),
|
|
126
|
+
storeRedis.invalidateCachePlugin({ cache: this.redisClient, invalidateCacheKeyGenerator }),
|
|
127
|
+
storeRedis.responseCachePlugin({ logger, cacheKeyGenerator }),
|
|
128
|
+
...(this.plugins ?? []),
|
|
129
|
+
];
|
|
130
|
+
// For classic express, add drain plugin to gracefully close the HTTP server.
|
|
131
|
+
// ultimate-express (uWebSockets.js) handles connection draining natively.
|
|
132
|
+
if (!expressAdapter.isUltimateEngine && this.wsServerHost) {
|
|
133
|
+
try {
|
|
134
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
135
|
+
const { ApolloServerPluginDrainHttpServer } = require('@apollo/server/plugin/drainHttpServer');
|
|
136
|
+
serverPlugins.push(ApolloServerPluginDrainHttpServer({ httpServer: this.wsServerHost }));
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
// Plugin not available — skip
|
|
140
|
+
}
|
|
141
|
+
}
|
|
120
142
|
const serverConfig = {
|
|
121
143
|
schema: this.moduleService.schema,
|
|
122
144
|
allowBatchedHttpRequests: true,
|
|
123
145
|
cache: cacheAdapter,
|
|
124
|
-
plugins:
|
|
125
|
-
drainHttpServer.ApolloServerPluginDrainHttpServer({ httpServer: this.httpServer }),
|
|
126
|
-
cacheControl.ApolloServerPluginCacheControl(),
|
|
127
|
-
storeRedis.invalidateCachePlugin({ cache: this.redisClient, invalidateCacheKeyGenerator }),
|
|
128
|
-
storeRedis.responseCachePlugin({ logger, cacheKeyGenerator }),
|
|
129
|
-
...(this.plugins ?? []),
|
|
130
|
-
],
|
|
146
|
+
plugins: serverPlugins,
|
|
131
147
|
};
|
|
132
148
|
if (this.enableSubscription) {
|
|
133
149
|
serverConfig.plugins.push({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GraphqlServer.cjs","sources":["../../src/servers/GraphqlServer.ts"],"sourcesContent":[null],"names":["WebSocketServer","config","GraphqlWs","
|
|
1
|
+
{"version":3,"file":"GraphqlServer.cjs","sources":["../../src/servers/GraphqlServer.ts"],"sourcesContent":[null],"names":["WebSocketServer","config","GraphqlWs","express","expressMiddleware","KeyvAdapter","ApolloServerPluginCacheControl","invalidateCachePlugin","responseCachePlugin","isUltimateEngine","ApolloServer"],"mappings":"+eAsBA,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,IA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EAAE,eAAe,EAAE,UAAU,EAAE,CAAC;yBAC7C;qBACJ,CAAC;AACF,oBAAA,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAChC,oBAAA,OAAO,QAAQ,CAAC;iBACnB;AACJ,aAAA,CAAC,CAAC;SACN;AAED,QAAA,OAAO,IAAIC,mBAAY,CAAC,YAAY,CAAC,CAAC;KACzC;AACJ"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {ApolloServer}from'@apollo/server';import {expressMiddleware}from'@apollo/server/express4';import {ApolloServerPluginCacheControl}from'@apollo/server/plugin/cacheControl';import
|
|
1
|
+
import {ApolloServer}from'@apollo/server';import {expressMiddleware}from'@apollo/server/express4';import {ApolloServerPluginCacheControl}from'@apollo/server/plugin/cacheControl';import'isomorphic-fetch';import {WebSocketServer,express,isUltimateEngine}from'../express-adapter.mjs';import cors from'cors';import Keyv from'keyv';import KeyvRedis from'@keyv/redis';import {KeyvAdapter}from'@apollo/utils.keyvadapter';import {invalidateCachePlugin,responseCachePlugin}from'@common-stack/store-redis';import {GraphqlWs}from'./GraphqlWs.mjs';import {config}from'../config/env-config.mjs';if ((process.env.LOG_LEVEL && process.env.LOG_LEVEL === 'trace') || process.env.LOG_LEVEL === 'debug') ;
|
|
2
2
|
// @workaround as the `dataSources` not available in Subscription (websocket) Context.
|
|
3
3
|
// https://github.com/apollographql/apollo-server/issues/1526 need to revisit in Apollo-Server v3.
|
|
4
4
|
const constructDataSourcesForSubscriptions = (context, cache, dataSources) => {
|
|
@@ -12,7 +12,7 @@ const constructDataSourcesForSubscriptions = (context, cache, dataSources) => {
|
|
|
12
12
|
};
|
|
13
13
|
class GraphqlServer {
|
|
14
14
|
app;
|
|
15
|
-
|
|
15
|
+
wsServerHost;
|
|
16
16
|
redisClient;
|
|
17
17
|
moduleService;
|
|
18
18
|
enableSubscription;
|
|
@@ -21,9 +21,10 @@ class GraphqlServer {
|
|
|
21
21
|
plugins;
|
|
22
22
|
logger;
|
|
23
23
|
graphqlWsServer;
|
|
24
|
-
constructor(app,
|
|
24
|
+
constructor(app, wsServerHost, // ultimate-express app or http.Server
|
|
25
|
+
redisClient, moduleService, enableSubscription = true, cacheKeyGenerator, invalidateCacheKeyGenerator, plugins) {
|
|
25
26
|
this.app = app;
|
|
26
|
-
this.
|
|
27
|
+
this.wsServerHost = wsServerHost;
|
|
27
28
|
this.redisClient = redisClient;
|
|
28
29
|
this.moduleService = moduleService;
|
|
29
30
|
this.enableSubscription = enableSubscription;
|
|
@@ -32,8 +33,11 @@ class GraphqlServer {
|
|
|
32
33
|
this.plugins = plugins;
|
|
33
34
|
this.logger = this.moduleService.logger.child({ className: 'GraphqlServer' });
|
|
34
35
|
if (enableSubscription) {
|
|
36
|
+
// WebSocketServer binds to different hosts depending on engine:
|
|
37
|
+
// - ultimate-express: pass the app as 'server' (ultimate-ws)
|
|
38
|
+
// - classic express: pass the httpServer as 'server' (ws)
|
|
35
39
|
const wsServer = new WebSocketServer({
|
|
36
|
-
server: this.
|
|
40
|
+
server: this.wsServerHost,
|
|
37
41
|
path: config.GRAPHQL_ENDPOINT,
|
|
38
42
|
});
|
|
39
43
|
this.graphqlWsServer = new GraphqlWs(wsServer, this.moduleService, this.redisClient);
|
|
@@ -117,17 +121,29 @@ class GraphqlServer {
|
|
|
117
121
|
const cacheSet = cacheAdapter.set.bind(cacheAdapter);
|
|
118
122
|
cacheAdapter.set = (key, value, opts) => cacheSet(key.replaceAll('fqc:', ''), value, opts);
|
|
119
123
|
const { cacheKeyGenerator, invalidateCacheKeyGenerator, logger } = this;
|
|
124
|
+
const serverPlugins = [
|
|
125
|
+
ApolloServerPluginCacheControl(),
|
|
126
|
+
invalidateCachePlugin({ cache: this.redisClient, invalidateCacheKeyGenerator }),
|
|
127
|
+
responseCachePlugin({ logger, cacheKeyGenerator }),
|
|
128
|
+
...(this.plugins ?? []),
|
|
129
|
+
];
|
|
130
|
+
// For classic express, add drain plugin to gracefully close the HTTP server.
|
|
131
|
+
// ultimate-express (uWebSockets.js) handles connection draining natively.
|
|
132
|
+
if (!isUltimateEngine && this.wsServerHost) {
|
|
133
|
+
try {
|
|
134
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
135
|
+
const { ApolloServerPluginDrainHttpServer } = require('@apollo/server/plugin/drainHttpServer');
|
|
136
|
+
serverPlugins.push(ApolloServerPluginDrainHttpServer({ httpServer: this.wsServerHost }));
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
// Plugin not available — skip
|
|
140
|
+
}
|
|
141
|
+
}
|
|
120
142
|
const serverConfig = {
|
|
121
143
|
schema: this.moduleService.schema,
|
|
122
144
|
allowBatchedHttpRequests: true,
|
|
123
145
|
cache: cacheAdapter,
|
|
124
|
-
plugins:
|
|
125
|
-
ApolloServerPluginDrainHttpServer({ httpServer: this.httpServer }),
|
|
126
|
-
ApolloServerPluginCacheControl(),
|
|
127
|
-
invalidateCachePlugin({ cache: this.redisClient, invalidateCacheKeyGenerator }),
|
|
128
|
-
responseCachePlugin({ logger, cacheKeyGenerator }),
|
|
129
|
-
...(this.plugins ?? []),
|
|
130
|
-
],
|
|
146
|
+
plugins: serverPlugins,
|
|
131
147
|
};
|
|
132
148
|
if (this.enableSubscription) {
|
|
133
149
|
serverConfig.plugins.push({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GraphqlServer.mjs","sources":["../../src/servers/GraphqlServer.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GraphqlServer.mjs","sources":["../../src/servers/GraphqlServer.ts"],"sourcesContent":[null],"names":[],"mappings":"skBAsBA,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,KAAK,OAAO,KAAK,OAAO,CAAC,GAAG,CAAC,SAAS,KAAK,OAAO,EAAE,CAEtG;AAED;AACA;AACA,MAAM,oCAAoC,GAAG,CAAC,OAAO,EAAE,KA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AAC;SACN;AAED,QAAA,OAAO,IAAI,YAAY,CAAC,YAAY,CAAC,CAAC;KACzC;AACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GraphqlWs.cjs","sources":["../../src/servers/GraphqlWs.ts"],"sourcesContent":[null],"names":["useServer","createWebSocketContext"],"mappings":"sIAmDa,SAAS,CAAA;AAMN,IAAA,QAAA,CAAA;AACA,IAAA,aAAA,CAAA;AACE,IAAA,KAAA,CAAA;AAPN,IAAA,kBAAkB,CAAa;AAE/B,IAAA,MAAM,CAAU;AAExB,IAAA,WAAA,CACY,
|
|
1
|
+
{"version":3,"file":"GraphqlWs.cjs","sources":["../../src/servers/GraphqlWs.ts"],"sourcesContent":[null],"names":["useServer","createWebSocketContext"],"mappings":"sIAmDa,SAAS,CAAA;AAMN,IAAA,QAAA,CAAA;AACA,IAAA,aAAA,CAAA;AACE,IAAA,KAAA,CAAA;AAPN,IAAA,kBAAkB,CAAa;AAE/B,IAAA,MAAM,CAAU;AAExB,IAAA,WAAA,CACY,QAA8C,EAC9C,aAA6B,EAC3B,KAAsC,EAAA;QAFxC,IAAQ,CAAA,QAAA,GAAR,QAAQ,CAAsC;QAC9C,IAAa,CAAA,aAAA,GAAb,aAAa,CAAgB;QAC3B,IAAK,CAAA,KAAA,GAAL,KAAK,CAAiC;QAEhD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;KAC3C;IAEM,MAAM,GAAA;AACT,QAAA,IAAI,CAAC,kBAAkB,GAAGA,YAAS,CAC/B;AACI,YAAA,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,MAAM;;;AAGjC,YAAA,OAAO,EAAE,OAAO,GAAG,KAAKC,uCAAsB,CAAC,GAAG,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCtF,SAAA,EACD,IAAI,CAAC,QAAQ,CAChB,CAAC;QACF,OAAO,IAAI,CAAC,kBAAkB,CAAC;KAClC;IAEM,UAAU,GAAA;AACb,QAAA,IAAI,IAAI,CAAC,kBAAkB,EAAE;AACzB,YAAA,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,CAAC;SACrC;KACJ;AACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GraphqlWs.mjs","sources":["../../src/servers/GraphqlWs.ts"],"sourcesContent":[null],"names":[],"mappings":"iIAmDa,SAAS,CAAA;AAMN,IAAA,QAAA,CAAA;AACA,IAAA,aAAA,CAAA;AACE,IAAA,KAAA,CAAA;AAPN,IAAA,kBAAkB,CAAa;AAE/B,IAAA,MAAM,CAAU;AAExB,IAAA,WAAA,CACY,
|
|
1
|
+
{"version":3,"file":"GraphqlWs.mjs","sources":["../../src/servers/GraphqlWs.ts"],"sourcesContent":[null],"names":[],"mappings":"iIAmDa,SAAS,CAAA;AAMN,IAAA,QAAA,CAAA;AACA,IAAA,aAAA,CAAA;AACE,IAAA,KAAA,CAAA;AAPN,IAAA,kBAAkB,CAAa;AAE/B,IAAA,MAAM,CAAU;AAExB,IAAA,WAAA,CACY,QAA8C,EAC9C,aAA6B,EAC3B,KAAsC,EAAA;QAFxC,IAAQ,CAAA,QAAA,GAAR,QAAQ,CAAsC;QAC9C,IAAa,CAAA,aAAA,GAAb,aAAa,CAAgB;QAC3B,IAAK,CAAA,KAAA,GAAL,KAAK,CAAiC;QAEhD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;KAC3C;IAEM,MAAM,GAAA;AACT,QAAA,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAC/B;AACI,YAAA,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,MAAM;;;AAGjC,YAAA,OAAO,EAAE,OAAO,GAAG,KAAK,sBAAsB,CAAC,GAAG,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCtF,SAAA,EACD,IAAI,CAAC,QAAQ,CAChB,CAAC;QACF,OAAO,IAAI,CAAC,kBAAkB,CAAC;KAClC;IAEM,UAAU,GAAA;AACb,QAAA,IAAI,IAAI,CAAC,kBAAkB,EAAE;AACzB,YAAA,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,CAAC;SACrC;KACJ;AACJ"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var expressAdapter=require('../express-adapter.cjs'),ws=require('graphql-ws/lib/use/ws'),websocketContext=require('./websocket-context.cjs'),envConfig=require('../config/env-config.cjs');class WebsocketMultiPathServer {
|
|
2
2
|
moduleService;
|
|
3
3
|
cache;
|
|
4
|
+
serverHost;
|
|
4
5
|
webSockets = {};
|
|
5
6
|
// private graphqlSubscriptionServer: GraphqlSubscriptionServer;
|
|
6
7
|
_graphqlWs;
|
|
@@ -8,17 +9,33 @@
|
|
|
8
9
|
maxConnections;
|
|
9
10
|
/** Whether connection limiting is enabled */
|
|
10
11
|
limitEnabled;
|
|
11
|
-
constructor(moduleService, cache,
|
|
12
|
+
constructor(moduleService, cache, serverHost, // ultimate-express app or http.Server for WebSocket binding
|
|
13
|
+
multiplePathConfig, limitConfig) {
|
|
12
14
|
this.moduleService = moduleService;
|
|
13
15
|
this.cache = cache;
|
|
16
|
+
this.serverHost = serverHost;
|
|
14
17
|
// Read from validated config (Kubernetes configmap) or use defaults
|
|
15
18
|
this.maxConnections = limitConfig?.maxConnections ?? envConfig.config.WEBSOCKET_MAX_CONNECTIONS;
|
|
16
19
|
this.limitEnabled = limitConfig?.limitEnabled ?? envConfig.config.WEBSOCKET_LIMIT_ENABLED;
|
|
17
|
-
|
|
20
|
+
// With the adapter, WebSocketServer works with both ultimate-ws and ws.
|
|
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 expressAdapter.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
|
+
});
|
|
18
35
|
this.webSockets[__GRAPHQL_ENDPOINT__] = this._graphqlWs;
|
|
19
36
|
// Initialize useServer ONCE for the GraphQL WebSocket server
|
|
20
37
|
// This prevents memory leaks from creating new listeners on each connection
|
|
21
|
-
ws
|
|
38
|
+
ws.useServer({
|
|
22
39
|
schema: moduleService.schema,
|
|
23
40
|
// Using shared context creation function to maintain consistency with GraphqlWs
|
|
24
41
|
context: async (ctx) => websocketContext.createWebSocketContext(ctx, moduleService, cache),
|
|
@@ -28,7 +45,18 @@
|
|
|
28
45
|
continue;
|
|
29
46
|
}
|
|
30
47
|
if (!this.webSockets[key]) {
|
|
31
|
-
this.webSockets[key] = new
|
|
48
|
+
this.webSockets[key] = new expressAdapter.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
|
+
});
|
|
32
60
|
this.webSockets[key].on('connection', (ws, request) => {
|
|
33
61
|
Promise.all([
|
|
34
62
|
moduleService.createContext(request, null),
|
|
@@ -38,37 +66,6 @@
|
|
|
38
66
|
}
|
|
39
67
|
}
|
|
40
68
|
}
|
|
41
|
-
httpServerUpgrade(httpServer) {
|
|
42
|
-
httpServer.on('upgrade', (request, socket, head) => {
|
|
43
|
-
const pathname = url__namespace.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
|
-
}
|
|
72
69
|
/**
|
|
73
70
|
* Get total number of active WebSocket connections across all paths
|
|
74
71
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebsocketMultipathUpdate.cjs","sources":["../../src/servers/WebsocketMultipathUpdate.ts"],"sourcesContent":[null],"names":["config","WebSocketServer","useServer","createWebSocketContext"
|
|
1
|
+
{"version":3,"file":"WebsocketMultipathUpdate.cjs","sources":["../../src/servers/WebsocketMultipathUpdate.ts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AAC,OAAO,EAAE,IAAI,CAAC;qBAC9C,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACzC,iBAAC,CAAC,CAAC;aACN;SACJ;KACJ;AAED;;AAEG;IACI,mBAAmB,GAAA;AACtB,QAAA,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,QAAQ,KAAK,KAAK,GAAI,QAAgB,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;KAChH;AAED;;AAEG;IACI,kBAAkB,GAAA;AAOrB,QAAA,MAAM,KAAK,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACzC,OAAO;YACH,KAAK;AACL,YAAA,OAAO,EAAG,IAAI,CAAC,UAAkB,CAAC,OAAO,CAAC,IAAI;YAC9C,cAAc,EAAE,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,6 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {WebSocketServer}from'../express-adapter.mjs';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;
|
|
4
5
|
webSockets = {};
|
|
5
6
|
// private graphqlSubscriptionServer: GraphqlSubscriptionServer;
|
|
6
7
|
_graphqlWs;
|
|
@@ -8,13 +9,29 @@ import*as url from'url';import {WebSocketServer}from'ws';import {useServer}from'
|
|
|
8
9
|
maxConnections;
|
|
9
10
|
/** Whether connection limiting is enabled */
|
|
10
11
|
limitEnabled;
|
|
11
|
-
constructor(moduleService, cache,
|
|
12
|
+
constructor(moduleService, cache, serverHost, // ultimate-express app or http.Server for WebSocket binding
|
|
13
|
+
multiplePathConfig, limitConfig) {
|
|
12
14
|
this.moduleService = moduleService;
|
|
13
15
|
this.cache = cache;
|
|
16
|
+
this.serverHost = serverHost;
|
|
14
17
|
// Read from validated config (Kubernetes configmap) or use defaults
|
|
15
18
|
this.maxConnections = limitConfig?.maxConnections ?? config.WEBSOCKET_MAX_CONNECTIONS;
|
|
16
19
|
this.limitEnabled = limitConfig?.limitEnabled ?? config.WEBSOCKET_LIMIT_ENABLED;
|
|
17
|
-
|
|
20
|
+
// With the adapter, WebSocketServer works with both ultimate-ws and ws.
|
|
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
|
+
});
|
|
18
35
|
this.webSockets[__GRAPHQL_ENDPOINT__] = this._graphqlWs;
|
|
19
36
|
// Initialize useServer ONCE for the GraphQL WebSocket server
|
|
20
37
|
// This prevents memory leaks from creating new listeners on each connection
|
|
@@ -28,7 +45,18 @@ import*as url from'url';import {WebSocketServer}from'ws';import {useServer}from'
|
|
|
28
45
|
continue;
|
|
29
46
|
}
|
|
30
47
|
if (!this.webSockets[key]) {
|
|
31
|
-
this.webSockets[key] = new WebSocketServer({
|
|
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
|
+
});
|
|
32
60
|
this.webSockets[key].on('connection', (ws, request) => {
|
|
33
61
|
Promise.all([
|
|
34
62
|
moduleService.createContext(request, null),
|
|
@@ -38,37 +66,6 @@ import*as url from'url';import {WebSocketServer}from'ws';import {useServer}from'
|
|
|
38
66
|
}
|
|
39
67
|
}
|
|
40
68
|
}
|
|
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
|
-
}
|
|
72
69
|
/**
|
|
73
70
|
* Get total number of active WebSocket connections across all paths
|
|
74
71
|
*/
|
|
@@ -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":"oNAsBa,wBAAwB,CAAA;AAWtB,IAAA,aAAA,CAAA;AACA,IAAA,KAAA,CAAA;AACC,IAAA,UAAA,CAAA;IAZJ,UAAU,GAAoB,EAAE,CAAC;;AAEjC,IAAA,UAAU,CAAuC;;AAGxC,IAAA,cAAc,CAAS;;AAEvB,IAAA,YAAY,CAAU;AAEvC,IAAA,WAAA,CACW,aAA6B,EAC7B,KAAsC,EACrC,UAAe;AACvB,IAAA,kBAAyC,EACzC,WAAkC,EAAA;QAJ3B,IAAa,CAAA,aAAA,GAAb,aAAa,CAAgB;QAC7B,IAAK,CAAA,KAAA,GAAL,KAAK,CAAiC;QACrC,IAAU,CAAA,UAAA,GAAV,UAAU,CAAK;;Q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,OAAO,EAAG,IAAI,CAAC,UAAkB,CAAC,OAAO,CAAC,IAAI;YAC9C,cAAc,EAAE,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@common-stack/server-stack",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.1-alpha.1",
|
|
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": "
|
|
36
|
-
"@common-stack/graphql-api": "
|
|
37
|
-
"@common-stack/store-redis": "
|
|
35
|
+
"@common-stack/codegen-zod": "9.0.1-alpha.1",
|
|
36
|
+
"@common-stack/graphql-api": "9.0.1-alpha.1",
|
|
37
|
+
"@common-stack/store-redis": "9.0.1-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",
|
|
@@ -77,14 +77,16 @@
|
|
|
77
77
|
"reflect-metadata": "^0.1.13",
|
|
78
78
|
"rxjs": "^7.8.1",
|
|
79
79
|
"subscriptions-transport-ws": "^0.11.0",
|
|
80
|
+
"ultimate-express": "^2.0.17",
|
|
81
|
+
"ultimate-ws": "^2.0.8",
|
|
80
82
|
"universal-cookie-express": "^4.0.1",
|
|
81
83
|
"ws": "^8.11.0",
|
|
82
84
|
"xstate": "^5.20.0",
|
|
83
85
|
"zod": "^4.0.0"
|
|
84
86
|
},
|
|
85
87
|
"devDependencies": {
|
|
86
|
-
"@common-stack/server-core": "
|
|
87
|
-
"common": "
|
|
88
|
+
"@common-stack/server-core": "9.0.1-alpha.1",
|
|
89
|
+
"common": "9.0.1-alpha.1"
|
|
88
90
|
},
|
|
89
91
|
"peerDependencies": {
|
|
90
92
|
"@cdm-logger/core": ">=7.0.12",
|
|
@@ -97,8 +99,8 @@
|
|
|
97
99
|
"publishConfig": {
|
|
98
100
|
"access": "public"
|
|
99
101
|
},
|
|
100
|
-
"gitHead": "b660069d9fb23784d2a755574be34938e5c8778b",
|
|
101
102
|
"typescript": {
|
|
102
103
|
"definition": "lib/index.d.ts"
|
|
103
|
-
}
|
|
104
|
+
},
|
|
105
|
+
"gitHead": "448e8a705be6483f6aa357d79098c43643ffa059"
|
|
104
106
|
}
|