@nsshunt/stsappframework 3.2.1 → 3.2.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.
Files changed (97) hide show
  1. package/dist/commonTypes.js +69 -0
  2. package/dist/commonTypes.js.map +1 -0
  3. package/dist/controller/stscontrollerbase.js +14 -0
  4. package/dist/controller/stscontrollerbase.js.map +1 -0
  5. package/dist/controller/stslatencycontroller.js +28 -0
  6. package/dist/controller/stslatencycontroller.js.map +1 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/logger/stsTransportLoggerWinston.js +22 -0
  9. package/dist/logger/stsTransportLoggerWinston.js.map +1 -0
  10. package/dist/logger/stsTransportWinston.js +43 -0
  11. package/dist/logger/stsTransportWinston.js.map +1 -0
  12. package/{src/middleware/serverNetworkMiddleware.ts → dist/middleware/serverNetworkMiddleware.js} +80 -124
  13. package/dist/middleware/serverNetworkMiddleware.js.map +1 -0
  14. package/dist/network.js +38 -0
  15. package/dist/network.js.map +1 -0
  16. package/dist/process/masterprocessbase.js +558 -0
  17. package/dist/process/masterprocessbase.js.map +1 -0
  18. package/{src/process/processbase.ts → dist/process/processbase.js} +150 -222
  19. package/dist/process/processbase.js.map +1 -0
  20. package/{src/process/serverprocessbase.ts → dist/process/serverprocessbase.js} +158 -212
  21. package/dist/process/serverprocessbase.js.map +1 -0
  22. package/dist/process/singleprocessbase.js +55 -0
  23. package/dist/process/singleprocessbase.js.map +1 -0
  24. package/{src/process/workerprocessbase.ts → dist/process/workerprocessbase.js} +93 -107
  25. package/dist/process/workerprocessbase.js.map +1 -0
  26. package/{src/publishertransports/publishTransportUtils.ts → dist/publishertransports/publishTransportUtils.js} +18 -24
  27. package/dist/publishertransports/publishTransportUtils.js.map +1 -0
  28. package/dist/route/stslatencyroute.js +15 -0
  29. package/dist/route/stslatencyroute.js.map +1 -0
  30. package/dist/route/stsrouterbase.js +21 -0
  31. package/dist/route/stsrouterbase.js.map +1 -0
  32. package/dist/stsexpressserver.js +115 -0
  33. package/dist/stsexpressserver.js.map +1 -0
  34. package/dist/validation/errors.js +10 -0
  35. package/dist/validation/errors.js.map +1 -0
  36. package/dist/vitesttesting/appConfig.js +93 -0
  37. package/dist/vitesttesting/appConfig.js.map +1 -0
  38. package/dist/vitesttesting/appSingleWSS.js +122 -0
  39. package/dist/vitesttesting/appSingleWSS.js.map +1 -0
  40. package/dist/vitesttesting/server.js +15 -0
  41. package/dist/vitesttesting/server.js.map +1 -0
  42. package/dist/vitesttesting/singleservertest.test.js +286 -0
  43. package/dist/vitesttesting/singleservertest.test.js.map +1 -0
  44. package/dist/vitesttesting/wsevents.js +3 -0
  45. package/dist/vitesttesting/wsevents.js.map +1 -0
  46. package/package.json +7 -3
  47. package/.github/dependabot.yml +0 -13
  48. package/.github/workflows/npm-publish.yml +0 -47
  49. package/.gitignore copy +0 -108
  50. package/build.sh +0 -37
  51. package/esbuild.config.js +0 -81
  52. package/eslint.config.mjs +0 -55
  53. package/jest/setEnvVars.js +0 -19
  54. package/keys/server.cert +0 -21
  55. package/keys/server.key +0 -28
  56. package/local-redis-stack.conf +0 -2
  57. package/run-grpc-client.sh +0 -2
  58. package/run-grpc-server.sh +0 -2
  59. package/run1.sh +0 -20
  60. package/run2.sh +0 -20
  61. package/run3.sh +0 -20
  62. package/runc1.sh +0 -19
  63. package/runc2.sh +0 -19
  64. package/runkafka.sh +0 -19
  65. package/runkafkaconsume01.sh +0 -21
  66. package/runkafkaconsume02.sh +0 -21
  67. package/runpromise.sh +0 -5
  68. package/runredis.sh +0 -5
  69. package/runredis1.sh +0 -4
  70. package/runredis2.sh +0 -24
  71. package/runredis3.sh +0 -4
  72. package/runtest1.sh +0 -19
  73. package/runtest2.sh +0 -19
  74. package/runtest_ipc_legacy.sh +0 -19
  75. package/runtest_ipcex.sh +0 -19
  76. package/runtest_redis.sh +0 -19
  77. package/runtest_ww.sh +0 -19
  78. package/src/commonTypes.ts +0 -374
  79. package/src/controller/stscontrollerbase.ts +0 -14
  80. package/src/controller/stslatencycontroller.ts +0 -26
  81. package/src/index.ts +0 -13
  82. package/src/logger/stsTransportLoggerWinston.ts +0 -24
  83. package/src/logger/stsTransportWinston.ts +0 -48
  84. package/src/network.ts +0 -36
  85. package/src/process/masterprocessbase.ts +0 -674
  86. package/src/process/singleprocessbase.ts +0 -63
  87. package/src/route/stslatencyroute.ts +0 -15
  88. package/src/route/stsrouterbase.ts +0 -21
  89. package/src/stsexpressserver.ts +0 -137
  90. package/src/validation/errors.ts +0 -6
  91. package/src/vitesttesting/appConfig.ts +0 -111
  92. package/src/vitesttesting/appSingleWSS.ts +0 -142
  93. package/src/vitesttesting/server.ts +0 -17
  94. package/src/vitesttesting/singleservertest.test.ts +0 -352
  95. package/src/vitesttesting/wsevents.ts +0 -44
  96. package/tsconfig.json +0 -42
  97. package/vite.config.ts +0 -19
@@ -1,63 +0,0 @@
1
- /* eslint @typescript-eslint/no-explicit-any: 0 */ // --> OFF
2
- import { goptions } from '@nsshunt/stsconfig'
3
-
4
- import { Gauge, GaugeTypes, InstrumentGaugeOptions, InstrumentGaugeTelemetry } from '@nsshunt/stsobservability'
5
-
6
- import { ISingleProcessBase, ProcessOptions } from './../commonTypes';
7
- import { InstrumentDefinitions } from '@nsshunt/stsobservability'
8
- import { ServerProcessBase } from './serverprocessbase'
9
-
10
- import si from 'systeminformation' // https://systeminformation.io/
11
-
12
- export type EventCb = (socket: any, data: any) => void
13
-
14
- export class SingleProcessBase extends ServerProcessBase implements ISingleProcessBase
15
- {
16
- /**
17
- *
18
- * @param {SingleProcessBaseOptions} options
19
- */
20
- constructor(options: ProcessOptions) {
21
- super(options)
22
- }
23
-
24
- override CollectAdditionalTelemetry(): void {
25
- const siValueObject = {
26
- currentLoad: 'currentLoad'
27
- }
28
- si.get(siValueObject).then(data => {
29
- this.UpdateInstrument(Gauge.CPU_SYSTEM_LOAD_GAUGE, {
30
- val: data.currentLoad.currentLoad
31
- } as InstrumentGaugeTelemetry);
32
- });
33
- }
34
-
35
- override GetAdditionalInstruments(): InstrumentDefinitions {
36
- return [
37
- [ Gauge.CPU_SYSTEM_LOAD_GAUGE, GaugeTypes.INSTRUMENT_GAUGE, {
38
- interval: goptions.instrumentationObservationInterval,
39
- sampleSize: goptions.instrumentationTimeWindow
40
- } as InstrumentGaugeOptions]
41
- ]
42
- }
43
-
44
- /**
45
- * UIController (instance of UIController) to manage a console based user interface associated for this node application.
46
- * @returns UIController instance to manage a console based user interface associated for this node application. Null for no capability.
47
- */
48
- override GetUIController(): any {
49
- return null;
50
- }
51
-
52
- override SetupServerEx = async (): Promise<boolean> => {
53
- await super.SetupServerEx();
54
-
55
- this.LogSystemTelemetry();
56
-
57
- return true;
58
- }
59
-
60
- async TerminateApplication() {
61
- await this.Terminate(false, 'SIGINT');
62
- }
63
- }
@@ -1,15 +0,0 @@
1
- import { STSRouterBase } from './stsrouterbase'
2
- import { STSLatencyController } from './../controller/stslatencycontroller'
3
- import { IProcessBase } from './../commonTypes'
4
-
5
- export class STSLatencyRoute extends STSRouterBase {
6
- constructor(stsApp: IProcessBase)
7
- {
8
- super(stsApp);
9
-
10
- const latencyController = new STSLatencyController(stsApp);
11
- const { stslatency } = latencyController;
12
-
13
- this.router.get('/latency', stslatency.bind(latencyController)); // Create new test
14
- }
15
- }
@@ -1,21 +0,0 @@
1
- /* eslint @typescript-eslint/no-explicit-any: 0 */ // --> OFF
2
- import { Router } from 'express';
3
- import { IProcessBase } from './../commonTypes';
4
-
5
- export abstract class STSRouterBase {
6
- #router: Router;
7
- #stsApp: any;
8
-
9
- constructor(stsApp: IProcessBase) {
10
- this.#stsApp = stsApp;
11
- this.#router = Router();
12
- }
13
-
14
- get router(): Router {
15
- return this.#router;
16
- }
17
-
18
- get stsApp(): IProcessBase {
19
- return this.#stsApp
20
- }
21
- }
@@ -1,137 +0,0 @@
1
- /* eslint @typescript-eslint/no-explicit-any: 0, @typescript-eslint/no-unused-vars: 0 */ // --> OFF
2
- import express, { Express, Request, Response, NextFunction } from 'express';
3
-
4
- import cors from 'cors';
5
- import cookieParser from 'cookie-parser';
6
-
7
- import { RequestLoggerMiddleware, RequestLoggerMiddlewareEventName } from '@nsshunt/stsobservability'
8
-
9
- import { goptions } from '@nsshunt/stsconfig'
10
-
11
- import { IProcessBase, ProcessOptions } from './commonTypes'
12
- import { Gauge, InstrumentGaugeTelemetry, InstrumentHistogramTelemetry, InstrumentVelocityTelemetry } from '@nsshunt/stsobservability'
13
-
14
- import { ISocketRecord, ServerNetworkMiddleware, ServerNetworkMiddlewareEventName } from './middleware/serverNetworkMiddleware'
15
-
16
- export class STSExpressServer {
17
- #app: Express;
18
-
19
- constructor(options: ProcessOptions, stsApp: IProcessBase)
20
- {
21
- // Standard RequestLoggerMiddleware for all STS services
22
- const requestLoggerMiddleware = new RequestLoggerMiddleware({
23
- ignoresocketio: goptions.ignoresocketio
24
- });
25
-
26
- const serverNetworkMiddleware = new ServerNetworkMiddleware({
27
- name: (stsApp.options as ProcessOptions).serviceName,
28
- outputDebug: false,
29
- logger: stsApp.options?.logger
30
- });
31
-
32
- serverNetworkMiddleware.on(ServerNetworkMiddlewareEventName.UpdateInstrument_SERVER_NET_VAL, (data: ISocketRecord) => {
33
- //this.#LogInfoMessage(chalk.magenta(`serverNetworkMiddleware: [${JSON.stringify(data)}]`));
34
- stsApp.UpdateInstrument(Gauge.NETWORK_RX_GAUGE, {
35
- Inc: data.requestBytesRead
36
- } as InstrumentGaugeTelemetry);
37
-
38
- stsApp.UpdateInstrument(Gauge.NETWORK_TX_GAUGE, {
39
- Inc: data.requestBytesWritten
40
- } as InstrumentGaugeTelemetry);
41
- });
42
-
43
- requestLoggerMiddleware.on(RequestLoggerMiddlewareEventName.UpdateInstrument_AR_INC, () => {
44
- stsApp.UpdateInstrument(Gauge.ACTIVE_REQUEST_GAUGE, {
45
- Inc: 1
46
- } as InstrumentGaugeTelemetry);
47
- });
48
-
49
- requestLoggerMiddleware.on(RequestLoggerMiddlewareEventName.UpdateInstrument_AR_DEC, () => {
50
- stsApp.UpdateInstrument(Gauge.ACTIVE_REQUEST_GAUGE, {
51
- Dec: 1
52
- } as InstrumentGaugeTelemetry);
53
- });
54
-
55
- requestLoggerMiddleware.on(RequestLoggerMiddlewareEventName.UpdateInstrument_DH_VAL, (timeInMs) => {
56
- stsApp.UpdateInstrument(Gauge.DURATION_HISTOGRAM_GAUGE, {
57
- val: timeInMs
58
- } as InstrumentHistogramTelemetry);
59
- });
60
-
61
- requestLoggerMiddleware.on(RequestLoggerMiddlewareEventName.UpdateInstrument_D_VAL, (timeInMs) => {
62
- stsApp.UpdateInstrument(Gauge.DURATION_GAUGE, {
63
- val: timeInMs
64
- } as InstrumentHistogramTelemetry);
65
- });
66
-
67
- requestLoggerMiddleware.on(RequestLoggerMiddlewareEventName.UpdateInstrument_RC_INC, () => {
68
- stsApp.UpdateInstrument(Gauge.REQUEST_COUNT_GAUGE, {
69
- Inc: 1
70
- } as InstrumentGaugeTelemetry);
71
- });
72
-
73
- requestLoggerMiddleware.on(RequestLoggerMiddlewareEventName.UpdateInstrument_V_INC, () => {
74
- if (stsApp.InstrumentExists(Gauge.VELOCITY_GAUGE)) {
75
- stsApp.UpdateInstrument(Gauge.VELOCITY_GAUGE, {
76
- Inc: 1
77
- } as InstrumentVelocityTelemetry);
78
- }
79
- });
80
-
81
- const app = express();
82
- this.#app = app;
83
-
84
- // https://stackoverflow.com/questions/19743396/cors-cannot-use-wildcard-in-access-control-allow-origin-when-credentials-flag-i
85
- // See answer from Christoph Hansen is thread above ...
86
- // https://expressjs.com/en/resources/middleware/cors.html
87
- const corsConfig = {
88
- credentials: true,
89
- origin: true,
90
- };
91
-
92
- app.use(cors(corsConfig));
93
-
94
- app.use(cookieParser())
95
-
96
- app.use(express.urlencoded({ extended: false, limit: goptions.maxPayloadSize }));
97
-
98
- app.use(express.json({limit: goptions.maxPayloadSize}));
99
-
100
- // Allow the static SPA to also be servered by this app
101
- //app.use('/static', express.static(path.join(__dirname, 'public')))
102
- if (options.expressServerRouteStaticFactory) {
103
- options.expressServerRouteStaticFactory(app, stsApp);
104
- }
105
-
106
- app.use(requestLoggerMiddleware.Middleware.bind(requestLoggerMiddleware));
107
-
108
- app.use(serverNetworkMiddleware.Middleware.bind(serverNetworkMiddleware));
109
-
110
- if (options.expressServerRouteFactory) {
111
- options.expressServerRouteFactory(app, stsApp);
112
- }
113
-
114
- // Express error handling fall-back
115
- app.use(function(err: any, req: Request, res: Response, next: NextFunction) {
116
- //@@ add to errors metric here - perhaps break down by type
117
-
118
- if (err) {
119
- //@@this.#LogInfoMessage(err);
120
- res.status(err.status).send(err);
121
- } else {
122
- next();
123
- }
124
- /*
125
- if(err.name === 'UnauthorizedError') {
126
- res.status(401).send(err);
127
- } else {
128
- next();
129
- }
130
- */
131
- });
132
- }
133
-
134
- get App(): Express {
135
- return this.#app;
136
- }
137
- }
@@ -1,6 +0,0 @@
1
- export const AppFrameworkErrorCode = Object.freeze({
2
- APPFRAMEWORK_MISSING_PERMISSION: {
3
- code: 'STS_AF_0001',
4
- description: 'STS_AF_0001: Missing Permission(s).'
5
- },
6
- });
@@ -1,111 +0,0 @@
1
- import { v4 as uuidv4 } from 'uuid';
2
- import express from 'express';
3
-
4
- import { goptions } from '@nsshunt/stsconfig'
5
-
6
- import { ProcessOptions, IProcessBase } from './..'
7
-
8
- import { STSExpressRouteFactory } from './server'
9
-
10
- import winston from 'winston'
11
-
12
- /*
13
- // nid: `${goptions.rest01servicename} @ ${goptions.rest01serviceversion} | ${this.options.globalServiceData.serviceInstanceId} @ ${os.hostname()} ^ ${process.pid} @ ${(cluster.isMaster ? process.pid : process.ppid)}`,
14
- // <serviceId> <serviceInstanceId> <serviceInstanceProcessId>
15
- // <serviceName> <serviceVersion> <sid> <hostName> <pid> <ppid>
16
- // << ............... Static Nid ............... >> << ............... Dynamic Nid ............... >>
17
- // Note: The final nid will NOT contain the NID_SEPERATOR character. This will be replaced with the SEPERATOR character.
18
- const Context = (isMaster, serviceInstanceId) => {
19
- return {
20
- nid: `\
21
- ${goptions.rest01servicename}${ModelDelimeter.COMPONENT_SEPERATOR}${goptions.rest01serviceversion}\
22
- ${ModelDelimeter.SEPERATOR}\
23
- ${serviceInstanceId}${ModelDelimeter.COMPONENT_SEPERATOR}${os.hostname()}\
24
- ${ModelDelimeter.NID_SEPERATOR}\
25
- ${process.pid}${ModelDelimeter.COMPONENT_SEPERATOR}${(isMaster ? process.pid : process.ppid)}`
26
- }
27
- }
28
- */
29
-
30
- export function ServiceConfigOptions(clusterMode: boolean, isMaster: boolean): ProcessOptions {
31
- winston.format.combine(
32
- winston.format.colorize(),
33
- winston.format.simple()
34
- );
35
-
36
- const logger = winston.createLogger({
37
- level: 'debug',
38
- format: winston.format.combine(
39
- winston.format.colorize(),
40
- winston.format.simple()
41
- ),
42
- transports: [
43
- new winston.transports.Console()
44
- ]
45
- });
46
-
47
- const publisherLogger = winston.createLogger({
48
- level: 'info',
49
- format: winston.format.combine(
50
- winston.format.colorize(),
51
- winston.format.simple()
52
- ),
53
- transports: [
54
- new winston.transports.Console()
55
- ]
56
- });
57
-
58
- if (isMaster === true) {
59
- const serviceInstanceId = uuidv4();
60
- const data: ProcessOptions = {
61
- clusterMode: clusterMode,
62
- wssServer: true,
63
- useLatency: true,
64
- httpsServerKeyPath: goptions.httpsserverkeypath,
65
- httpsServerCertificatePath: goptions.httpsservercertpath,
66
- processExitOnTerminate: true,
67
- serviceInstanceId: serviceInstanceId,
68
- useDatabase: false,
69
-
70
- isMaster: isMaster,
71
- endpoint: goptions.rest01endpoint,
72
- apiRoot: goptions.rest01apiroot,
73
- listenPort: goptions.rest01hostport,
74
- port: goptions.rest01port,
75
- prometheusSupport: goptions.rest01prometheussupport,
76
- prometheusClusterPort: goptions.rest01prometheusclusterport,
77
- serviceName: goptions.rest01servicename,
78
- serviceVersion: goptions.rest01serviceversion,
79
- consoleLogging: false, //@@
80
- instrumentLogging: true,
81
-
82
- instrumentationObservationInterval: goptions.instrumentationObservationInterval,
83
- instrumentationTimeWindow: goptions.instrumentationTimeWindow,
84
-
85
- useSocketIoRedisAdaptor: true,
86
- socketIoRedisAdaptorUrl: goptions.socketIoRedisAdaptorUrl,
87
- //socketIoRedisAdaptorUrl: 'redis://192.168.50.5:6379',
88
- //workerExec: './dist/testing/app.js',
89
-
90
- logger: logger,
91
- publisherLogger: publisherLogger,
92
- publishInterval: goptions.publishinterval
93
- }
94
-
95
- if (!clusterMode) {
96
- data.expressServerRouteFactory = (app: express.Express, stsApp: IProcessBase) => {
97
- return new STSExpressRouteFactory(app, stsApp);
98
- }
99
- }
100
-
101
- return data;
102
- } else {
103
- const data: ProcessOptions = JSON.parse(process.env['STS_GSD_SII'] as string) as ProcessOptions;
104
- data.expressServerRouteFactory = (app: express.Express, stsApp: IProcessBase) => {
105
- return new STSExpressRouteFactory(app, stsApp);
106
- }
107
- data.logger = logger;
108
- data.publisherLogger = publisherLogger;
109
- return data;
110
- }
111
- }
@@ -1,142 +0,0 @@
1
- /* eslint @typescript-eslint/no-explicit-any: 0 */ // --> OFF
2
- import chalk from 'chalk';
3
-
4
- import { SingleProcessBase, ProcessOptions } from './../index'
5
- import { SocketIoServerHelper, STSNamespace, STSRoom, InterServerEvents } from '@nsshunt/stssocketioutils'
6
-
7
- import { Namespace, Socket } from "socket.io";
8
-
9
- import { ClientToServerEvents, ServerToClientEvents } from './wsevents'
10
- import { JSONObject } from '@nsshunt/stsutils';
11
-
12
- export class AppSingleWSS extends SingleProcessBase
13
- {
14
- constructor(options: ProcessOptions) {
15
- super(options);
16
- }
17
-
18
- #LogInfoMessage(message: any) {
19
- this.options.logger.info(message);
20
- }
21
-
22
- #SetupWSSServer = (namespace: STSNamespace) => {
23
-
24
-
25
-
26
- this.socketIoServerHelper = new SocketIoServerHelper<ClientToServerEvents, ServerToClientEvents>({
27
- logger: this.options.logger
28
- });
29
-
30
-
31
- //this.io?.of('/stsinstrumentmanager/stsmonitor/');
32
- //return;
33
-
34
- //this.socketIoServerHelper.SetupNamespaceEx(this.io as any, '/stsinstrumentmanager/stsmonitor/' as any);
35
- //return;
36
-
37
-
38
- this.socketIoServerHelper.SetupNamespace(this.io as any, namespace,
39
- // Auto joinn room list
40
- [
41
- STSRoom.STSInstrumentDataRoom,
42
- STSRoom.STSRunnerRoom,
43
- 'room3'
44
- ],
45
- true, // Make any connecting client automatically join the room list above
46
-
47
- // Connect call back when a client connects
48
- (socket: Socket<ClientToServerEvents, ServerToClientEvents, InterServerEvents>) => {
49
- this.#LogInfoMessage(chalk.gray(`AppSingleWSS.#SetupWSSServer: Id: [${socket.id}] eventName: [connect]`));
50
- },
51
-
52
- // Custom client to server events
53
- (socket: Socket<ClientToServerEvents, ServerToClientEvents, InterServerEvents>) => {
54
- socket.on('subscribe', (data: any) => {
55
- socket.emit('subscribeAck', data);
56
- });
57
- socket.on('unsubscribe', (data: any) => {
58
- socket.emit('unsubscribeAck', data);
59
- });
60
- socket.on('subscribeKeepAlive', (data: any) => {
61
- socket.emit('subscribeKeepAliveAck', data);
62
- });
63
- socket.on('done', () => {
64
- socket.emit('doneAck');
65
- });
66
- socket.on('compute', (arg: number, cb) => {
67
- const res = arg * 2;
68
- cb(res.toString());
69
- });
70
- socket.on('compute2', (arg, cb) => {
71
- cb({data: arg*2});
72
- });
73
- socket.on('broadcast', () => {
74
-
75
- if (this.socketIoServerHelper) {
76
- const namespaceIo = this.socketIoServerHelper
77
- .GetSTSSocketIONamespace(namespace).socketionamespace as Namespace<ClientToServerEvents, ServerToClientEvents, InterServerEvents>
78
-
79
- namespaceIo.to("room3").timeout(5000).emit("compute3", 10, (err: Error, data: JSONObject[]) => {
80
- if (err) {
81
- console.log(`room3 broadcast: [${chalk.red(JSON.stringify(err))}]`)
82
- } else {
83
- console.log(`room3 broadcast: [${chalk.blue(JSON.stringify(data))}]`)
84
- }
85
- });
86
- }
87
- });
88
-
89
- socket.on('__STSsendToRoomWithCB', (rooms: string[], payload: { command: string, payload: JSONObject }): void => {
90
- rooms.forEach((room) => {
91
- //this.LogMessage(namespace, `${namespace.socketionamespace.name}:socket.on:sendToRoom: __STSsendToRoom: Sending to room [${room}], ID: [${socket.id}]`);
92
-
93
- if (this.socketIoServerHelper) {
94
- const namespaceIo = this.socketIoServerHelper
95
- .GetSTSSocketIONamespace(namespace).socketionamespace as Namespace<ClientToServerEvents, ServerToClientEvents, InterServerEvents>
96
-
97
- namespaceIo.to(room).timeout(5000).emit(payload.command as any, payload, (err: Error, data: JSONObject[]) => {
98
- if (err) {
99
- console.error(err);
100
- console.log(`__STSsendToRoomWithCB broadcast: [${chalk.red(JSON.stringify(err))}]`)
101
- } else {
102
- console.log(`__STSsendToRoomWithCB broadcast: [${chalk.blue(JSON.stringify(data))}]`)
103
- }
104
- });
105
- }
106
- });
107
- });
108
-
109
- socket.on('GetThreadDetails', (inputThreaddata: JSONObject, cb: (data: JSONObject) => void) => {
110
- if (this.socketIoServerHelper) {
111
- const namespaceIo = this.socketIoServerHelper
112
- .GetSTSSocketIONamespace(namespace).socketionamespace as Namespace<ClientToServerEvents, ServerToClientEvents, InterServerEvents>
113
-
114
- namespaceIo.to(inputThreaddata.room).timeout(5000).emit('GetThreadDetailsFromService', { data: inputThreaddata }, (err: Error, data: JSONObject[]) => {
115
- if (err) {
116
- console.error(err);
117
- console.log(`__STSsendToRoomWithCB broadcast: [${chalk.red(JSON.stringify(err))}]`)
118
- } else {
119
- console.log(`__STSsendToRoomWithCB broadcast: [${chalk.blue(JSON.stringify(data))}]`)
120
- cb(data);
121
- }
122
- });
123
- }
124
- });
125
- })
126
- }
127
-
128
- override ProcessStarted() {
129
- super.ProcessStarted();
130
-
131
- /*
132
- const nsp = this.io?.of('/stsinstrumentmanager/stsmonitor');
133
- nsp?.on("connection", socket => {
134
-
135
- });
136
- this.#SetupConnectionMiddleware(nsp);
137
- */
138
-
139
- this.#SetupWSSServer(STSNamespace.STSMonitor);
140
- //this.#SetupWSSServer('stsinstrumentmanager/stsmonitor' as any);
141
- }
142
- }
@@ -1,17 +0,0 @@
1
- import express from 'express';
2
-
3
- import { STSLatencyRoute, IProcessBase } from './..'
4
-
5
- import { goptions } from '@nsshunt/stsconfig'
6
-
7
- export class STSExpressRouteFactory
8
- {
9
- constructor(app: express.Express, stsApp: IProcessBase)
10
- {
11
- const stslatency = new STSLatencyRoute(stsApp);
12
-
13
- // Note: This MUST come first as the latency end point is on the same path as the reosurce path.
14
- // If stsresourceRouter came first, it would think that /latency was a resource name.
15
- app.use(`${goptions.rest01apiroot}`, stslatency.router);
16
- }
17
- }