@rvoh/psychic-websockets 0.2.0 → 0.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.
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const psychic_1 = require("@rvoh/psychic");
4
4
  const redis_adapter_1 = require("@socket.io/redis-adapter");
5
- const colors = require("colorette");
5
+ const yoctocolors_1 = require("yoctocolors");
6
6
  const socketio = require("socket.io");
7
7
  const MissingWsRedisConnection_js_1 = require("../error/ws/MissingWsRedisConnection.js");
8
8
  const EnvInternal_js_1 = require("../helpers/EnvInternal.js");
@@ -25,7 +25,7 @@ class Cable {
25
25
  this.httpServer = psychic_1.PsychicServer.createPsychicHttpInstance(this.app, this.config.psychicApp.sslCredentials);
26
26
  this.io = new socketio.Server(this.httpServer, { cors: this.config.psychicApp.corsOptions });
27
27
  }
28
- async start(port, { withFrontEndClient = false, frontEndPort = 3000, } = {}) {
28
+ async start(port) {
29
29
  this.connect();
30
30
  for (const hook of this.config.hooks.wsStart) {
31
31
  await hook(this.io);
@@ -60,8 +60,6 @@ class Cable {
60
60
  const psychicAppWebsockets = index_js_1.default.getOrFail();
61
61
  await this.listen({
62
62
  port: parseInt((port || psychicAppWebsockets.psychicApp.port).toString()),
63
- withFrontEndClient,
64
- frontEndPort,
65
63
  });
66
64
  }
67
65
  async stop() {
@@ -80,17 +78,15 @@ class Cable {
80
78
  }
81
79
  }
82
80
  }
83
- async listen({ port, withFrontEndClient, frontEndPort, }) {
81
+ async listen({ port }) {
84
82
  return new Promise(accept => {
85
83
  this.httpServer.listen(port, () => {
86
84
  if (!EnvInternal_js_1.default.isTest) {
87
85
  const app = index_js_1.default.getOrFail().psychicApp;
88
86
  app.logger.info(psychic_1.PsychicServer.asciiLogo());
89
87
  app.logger.info('\n');
90
- app.logger.info(colors.cyan('socket server started '));
91
- app.logger.info(colors.cyan(`psychic dev server started at port ${colors.bgBlueBright(colors.green(port))}`));
92
- if (withFrontEndClient)
93
- app.logger.info(`client server started at port ${colors.cyan(frontEndPort)}`);
88
+ app.logger.info(yoctocolors_1.default.cyan('socket server started '));
89
+ app.logger.info(yoctocolors_1.default.cyan(`psychic dev server started at port ${yoctocolors_1.default.bgBlueBright(yoctocolors_1.default.green(port.toString()))}`));
94
90
  app.logger.info('\n');
95
91
  }
96
92
  accept(true);
@@ -10,12 +10,9 @@ class PsychicApplicationWebsockets {
10
10
  const cable = psychicServer.$attached.cable;
11
11
  await cable?.stop();
12
12
  });
13
- psychicApp.override('server:start', async (psychicServer, { port, withFrontEndClient, frontEndPort }) => {
13
+ psychicApp.override('server:start', async (psychicServer, { port }) => {
14
14
  const cable = new index_js_1.default(psychicServer.expressApp, psychicWsApp);
15
- await cable.start(port, {
16
- withFrontEndClient,
17
- frontEndPort,
18
- });
15
+ await cable.start(port);
19
16
  psychicServer.attach('cable', cable);
20
17
  return cable.httpServer;
21
18
  });
@@ -1,6 +1,6 @@
1
1
  import { PsychicServer } from '@rvoh/psychic';
2
2
  import { createAdapter } from '@socket.io/redis-adapter';
3
- import * as colors from 'colorette';
3
+ import colors from 'yoctocolors';
4
4
  import * as socketio from 'socket.io';
5
5
  import MissingWsRedisConnection from '../error/ws/MissingWsRedisConnection.js';
6
6
  import EnvInternal from '../helpers/EnvInternal.js';
@@ -23,7 +23,7 @@ export default class Cable {
23
23
  this.httpServer = PsychicServer.createPsychicHttpInstance(this.app, this.config.psychicApp.sslCredentials);
24
24
  this.io = new socketio.Server(this.httpServer, { cors: this.config.psychicApp.corsOptions });
25
25
  }
26
- async start(port, { withFrontEndClient = false, frontEndPort = 3000, } = {}) {
26
+ async start(port) {
27
27
  this.connect();
28
28
  for (const hook of this.config.hooks.wsStart) {
29
29
  await hook(this.io);
@@ -58,8 +58,6 @@ export default class Cable {
58
58
  const psychicAppWebsockets = PsychicApplicationWebsockets.getOrFail();
59
59
  await this.listen({
60
60
  port: parseInt((port || psychicAppWebsockets.psychicApp.port).toString()),
61
- withFrontEndClient,
62
- frontEndPort,
63
61
  });
64
62
  }
65
63
  async stop() {
@@ -78,7 +76,7 @@ export default class Cable {
78
76
  }
79
77
  }
80
78
  }
81
- async listen({ port, withFrontEndClient, frontEndPort, }) {
79
+ async listen({ port }) {
82
80
  return new Promise(accept => {
83
81
  this.httpServer.listen(port, () => {
84
82
  if (!EnvInternal.isTest) {
@@ -86,9 +84,7 @@ export default class Cable {
86
84
  app.logger.info(PsychicServer.asciiLogo());
87
85
  app.logger.info('\n');
88
86
  app.logger.info(colors.cyan('socket server started '));
89
- app.logger.info(colors.cyan(`psychic dev server started at port ${colors.bgBlueBright(colors.green(port))}`));
90
- if (withFrontEndClient)
91
- app.logger.info(`client server started at port ${colors.cyan(frontEndPort)}`);
87
+ app.logger.info(colors.cyan(`psychic dev server started at port ${colors.bgBlueBright(colors.green(port.toString()))}`));
92
88
  app.logger.info('\n');
93
89
  }
94
90
  accept(true);
@@ -8,12 +8,9 @@ export default class PsychicApplicationWebsockets {
8
8
  const cable = psychicServer.$attached.cable;
9
9
  await cable?.stop();
10
10
  });
11
- psychicApp.override('server:start', async (psychicServer, { port, withFrontEndClient, frontEndPort }) => {
11
+ psychicApp.override('server:start', async (psychicServer, { port }) => {
12
12
  const cable = new Cable(psychicServer.expressApp, psychicWsApp);
13
- await cable.start(port, {
14
- withFrontEndClient,
15
- frontEndPort,
16
- });
13
+ await cable.start(port);
17
14
  psychicServer.attach('cable', cable);
18
15
  return cable.httpServer;
19
16
  });
@@ -10,15 +10,10 @@ export default class Cable {
10
10
  private redisConnections;
11
11
  constructor(app: Application, config: PsychicApplicationWebsockets);
12
12
  connect(): void;
13
- start(port?: number, { withFrontEndClient, frontEndPort, }?: {
14
- withFrontEndClient?: boolean;
15
- frontEndPort?: number;
16
- }): Promise<void>;
13
+ start(port?: number): Promise<void>;
17
14
  stop(): Promise<void>;
18
- listen({ port, withFrontEndClient, frontEndPort, }: {
15
+ listen({ port }: {
19
16
  port: number | string;
20
- withFrontEndClient: boolean;
21
- frontEndPort: number;
22
17
  }): Promise<unknown>;
23
18
  bindToRedis(): void;
24
19
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "type": "module",
3
3
  "name": "@rvoh/psychic-websockets",
4
4
  "description": "Websocket system for Psychic applications",
5
- "version": "0.2.0",
5
+ "version": "0.2.2",
6
6
  "author": "RVOHealth",
7
7
  "repository": "https://github.com/rvohealth/psychic-websockets.git",
8
8
  "license": "MIT",
@@ -43,9 +43,9 @@
43
43
  },
44
44
  "devDependencies": {
45
45
  "@eslint/js": "=9.0.0",
46
- "@rvoh/dream": "^0.29.1",
47
- "@rvoh/dream-spec-helpers": "^0.1.0",
48
- "@rvoh/psychic": "^0.24.0",
46
+ "@rvoh/dream": "^0.31.0",
47
+ "@rvoh/dream-spec-helpers": "^0.2.0",
48
+ "@rvoh/psychic": "^0.25.0",
49
49
  "@rvoh/psychic-spec-helpers": "^0.2.0",
50
50
  "@socket.io/redis-adapter": "^8.3.0",
51
51
  "@socket.io/redis-emitter": "^5.1.0",
@@ -76,5 +76,8 @@
76
76
  "typescript-eslint": "=7.18.0",
77
77
  "vitest": "^3.0.8"
78
78
  },
79
- "packageManager": "yarn@4.4.1"
80
- }
79
+ "packageManager": "yarn@4.4.1",
80
+ "dependencies": {
81
+ "yoctocolors": "^2.1.1"
82
+ }
83
+ }