From 33db54145e6a8311a51da80e8f3a109e3c27bbab Mon Sep 17 00:00:00 2001 From: Luisa Date: Tue, 1 Mar 2022 07:35:05 +0100 Subject: [PATCH 1/2] DELETE websocket server and change object --- src/Instantiator.ts | 2 - src/Services.ts | 12 -- src/api/ApiV1.ts | 8 -- src/api/WebSocketApi.ts | 154 ------------------------- src/domain/ChangeSendingTransaction.ts | 28 ----- src/domain/DbMigration.ts | 12 +- src/domain/DbSchema.ts | 13 --- src/domain/change/Change.ts | 32 ----- src/domain/change/ChangeLogic.ts | 60 ---------- src/domain/change/validators.ts | 20 ---- 10 files changed, 1 insertion(+), 340 deletions(-) delete mode 100644 src/api/WebSocketApi.ts delete mode 100644 src/domain/ChangeSendingTransaction.ts delete mode 100644 src/domain/change/Change.ts delete mode 100644 src/domain/change/ChangeLogic.ts delete mode 100644 src/domain/change/validators.ts diff --git a/src/Instantiator.ts b/src/Instantiator.ts index 5fb5abd..548daa6 100644 --- a/src/Instantiator.ts +++ b/src/Instantiator.ts @@ -1,13 +1,11 @@ import { Result } from 'coderitter-api-remote-method-call' import { Changes } from 'knight-change' import { CountResult, CreateOrGetResult, EntitiesResult, EntitiesVersionResult, EntityResult } from './domain/api' -import Change from './domain/change/Change' import Knight from './domain/knight/Knight' export default { // change 'Changes': () => new Changes, - 'Change': () => new Change, //knight 'Knight': () => new Knight, diff --git a/src/Services.ts b/src/Services.ts index e1b9acc..1447a13 100644 --- a/src/Services.ts +++ b/src/Services.ts @@ -4,9 +4,7 @@ import { Log } from 'knight-log' import WebSocket from 'ws' import ApiV1 from './api/ApiV1' import HttpApi from './api/HttpApi' -import WebSocketApi from './api/WebSocketApi' import { getConfigByArgvOrEnvOrDefault, test } from './config' -import ChangeLogic from './domain/change/ChangeLogic' import DbMigration from './domain/DbMigration' import DemoData from './domain/DemoData' import instantiator from './Instantiator' @@ -36,11 +34,9 @@ export default class Services { apiV1 = new ApiV1 httpApi!: HttpApi - webSocketApi!: WebSocketApi orm = new Orm(schema, 'postgres') - changeLogic = new ChangeLogic() knightLogic = new KnightLogic() async start() { @@ -55,7 +51,6 @@ export default class Services { inject() { this.knightLogic.orm = this.orm - this.changeLogic.orm = this.orm } @@ -81,17 +76,10 @@ export default class Services { this.httpApi = new HttpApi(this.apiV1, instantiator, this.config.httpApi) this.httpApi.server = this.httpServer - this.webSocketApi = new WebSocketApi - this.webSocketApi.webSocketServer = this.webSocketServer - this.webSocketApi.pool = this.pool - this.webSocketApi.changeLogic = this.changeLogic - this.apiV1.pool = this.pool - this.apiV1.webSocketApi = this.webSocketApi this.httpApi.start() log.admin('Started HTTP API (POSTonly)') - this.webSocketApi.start() log.admin('Started WebSocket API') log.admin('Initialized HTTP API with remote methods', this.apiV1.methodNames) diff --git a/src/api/ApiV1.ts b/src/api/ApiV1.ts index d49186b..e79e6a5 100644 --- a/src/api/ApiV1.ts +++ b/src/api/ApiV1.ts @@ -3,16 +3,13 @@ import { PgTransaction } from 'knight-pg-transaction' import { Pool } from 'pg' import { Log } from 'knight-log' -import { ChangeSendingTransaction } from '../domain/ChangeSendingTransaction' import Services from '../Services' -import WebSocketApi from './WebSocketApi' let log = new Log('ApiV1.ts') export default class Api extends RemoteMethodApi { pool!: Pool - webSocketApi!: WebSocketApi start() { this.methods = { @@ -22,9 +19,4 @@ export default class Api extends RemoteMethodApi { tx(): PgTransaction { return new PgTransaction(this.pool) } - - chgTx(): ChangeSendingTransaction { - log.mt('chgTx') - return new ChangeSendingTransaction(this.pool, Services.get().changeLogic, this.webSocketApi) - } } \ No newline at end of file diff --git a/src/api/WebSocketApi.ts b/src/api/WebSocketApi.ts deleted file mode 100644 index 4498dea..0000000 --- a/src/api/WebSocketApi.ts +++ /dev/null @@ -1,154 +0,0 @@ -import { Changes } from 'knight-change' -import { toJson } from 'knight-json' -import { PgTransaction } from 'knight-pg-transaction' -import { Pool } from 'pg' -import { Log } from 'knight-log' -import WebSocket from 'ws' -import ChangeLogic from '../domain/change/ChangeLogic' - -let log = new Log('WebSocketApi.ts') - -export default class WebSocketApi { - - webSocketServer!: WebSocket.Server - pool!: Pool - changeLogic!: ChangeLogic - - lastVersion?: number - sendingChanges = false - pingInterval?: NodeJS.Timeout - - start() { - this.webSocketServer.on('connection', (socket, request) => { - let l = log.fn('onConnection') - l.admin('New WebSocket connection from ' + request.connection.remoteAddress) - - socket.on('message', (data: WebSocket.Data) => { - let l = log.fn('onMessage') - - if (typeof data == 'string') { - l.dev('data', data) - - if (data == 'pong') { - l.admin('Received pong...') - ; (socket as any).isAlive = true - } - else { - l.admin('Received version number...') - let version = parseInt(data) - l.dev('version', version) - - if (isNaN(version)) { - l.error('Received version is not a number. Returning...') - return - } - - l.admin('Received version. Sending changes...') - this.sendChanges(version, socket) - } - } - }) - }) - - this.webSocketServer.on('close', () => { - if (this.pingInterval) { - clearInterval(this.pingInterval) - } - }) - - this.webSocketServer.on('error', error => { - log.error('WebSocket error ' + error.message) - }) - - this.pingInterval = setInterval(() => { - let l = log.fn('onPingInterval') - - if (this.webSocketServer.clients.size == 0) { - l.admin('No connected clients. Returning...') - return - } - - for (let client of this.webSocketServer.clients) { - if ((client as any).isAlive === false) { - l.admin('Found dead client. Terminating...') - client.terminate() - continue - } - - ; (client as any).isAlive = false - l.admin('Pinging client...') - client.send('ping') - } - }, 30000) - } - - async sendChanges(lastVersion: number, client?: WebSocket) { - let l = log.mt('sendChanges') - l.dev('versionBefore', lastVersion) - - l.admin('Retrieving all changes since the last ones...') - - let changeReadResult - try { - changeReadResult = await this.changeLogic.read({ version: { operator: '>', value: lastVersion }, '@orderBy': 'version' }, new PgTransaction(this.pool)) - } - catch (e) { - l.error(e) - throw new Error(e) - } - - l.dev('changeReadResult', changeReadResult) - - let changes = new Changes - changes.changes = changeReadResult.entities - - let clients: WebSocket[] - if (client != undefined) { - if (!(client as any).sendingChanges) { - l.admin('Using single given WebSocket client...') - clients = [client] - } - else { - l.admin('Client is already sending changes. Returning...') - return - } - } - else { - l.admin('Using all clients which are not sending...') - - clients = [] - for (let client of this.webSocketServer.clients) { - if ((client as any).sendingChanges) { - l.admin('Client is already sending changes. Continuing...') - continue - } - - (client as any).sendingChanges = true - clients.push(client) - } - } - - - l.admin('Converting changes to json...') - let changesJson = toJson(changes) - l.dev('changesJson', changesJson) - - l.admin('Sending changes to every client...') - - for (let client of clients) { - l.dev('client', (client as any)._socket._peername.address) - - client.send(changesJson, (e: Error | undefined) => { - if (e != undefined) { - l.error(e) - } - }) - } - - l.admin('Setting all clients to not sending...') - - for (let client of clients) { - (client as any).sendingChanges = false - } - } -} diff --git a/src/domain/ChangeSendingTransaction.ts b/src/domain/ChangeSendingTransaction.ts deleted file mode 100644 index fdd1158..0000000 --- a/src/domain/ChangeSendingTransaction.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { PgTransaction } from 'knight-pg-transaction' -import { Pool } from 'pg' -import { Log } from 'knight-log' -import WebSocketApi from '../api/WebSocketApi' -import ChangeLogic from '../domain/change/ChangeLogic' - -let log = new Log('ChangeSendingTransaction.ts') - -export class ChangeSendingTransaction extends PgTransaction { - - versionBefore?: number - - constructor(pool: Pool, changeLogic: ChangeLogic, webSocketApi: WebSocketApi) { - super(pool) - - this.afterBegin(async () => { - let l = log.fn('onAfterBegin') - this.versionBefore = await changeLogic.latestVersion(this) - l.dev('this.versionBefore', this.versionBefore) - }) - - this.afterCommit(() => { - if (this.versionBefore) { - webSocketApi.sendChanges(this.versionBefore) - } - }) - } -} diff --git a/src/domain/DbMigration.ts b/src/domain/DbMigration.ts index 3c05779..1cba6dc 100644 --- a/src/domain/DbMigration.ts +++ b/src/domain/DbMigration.ts @@ -21,16 +21,6 @@ export default class DbMigration extends PostgresMigration { return } - await this.pool.query(` - CREATE TABLE Change ( - version SERIAL PRIMARY KEY, - entityName VARCHAR(100), - method VARCHAR(20), - entity TEXT, - description TEXT - )` - ) - await this.pool.query(` create table knight( id SERIAL PRIMARY KEY, @@ -39,6 +29,6 @@ export default class DbMigration extends PostgresMigration { );`) await this.increaseVersion() - log.admin('Migrated to version 1 (Add change table and table knight)') + log.admin('Migrated to version 1 (Add table knight)') } } diff --git a/src/domain/DbSchema.ts b/src/domain/DbSchema.ts index 6d47701..f74dfb0 100644 --- a/src/domain/DbSchema.ts +++ b/src/domain/DbSchema.ts @@ -1,21 +1,8 @@ import { Schema } from 'knight-orm' -import Change from './change/Change' import Knight from './knight/Knight' export const schema = new Schema -schema.addTable('change', { - columns: { - 'version': { property: 'version', primaryKey: true, generated: true }, - 'entityname': 'entityName', - 'method': 'method', - 'entity': 'entity' - }, - relationships: {}, - newInstance: () => new Change -} -) - schema.addTable('knight', { columns: { 'id': { property: 'id', primaryKey: true, generated: true }, diff --git a/src/domain/change/Change.ts b/src/domain/change/Change.ts deleted file mode 100644 index 69a4061..0000000 --- a/src/domain/change/Change.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { Change as KnightChange, Method } from 'knight-change' - -export default class Change extends KnightChange { - - version?: number - - constructor() - constructor(entity: object) - constructor(entity: object, method: string) - constructor(entity: object, method: Method) - constructor(entity: object, methods: (string | Method)[]) - constructor(entityName: string) - constructor(entityName: string, entity: object) - constructor(entityName: string, entity: object, method: string) - constructor(entityName: string, entity: object, method: Method) - constructor(entityName: string, entity: object, methods: (string | Method)[]) - constructor(entityName: string, method: string) - constructor(entityName: string, method: Method) - constructor(entityName: string, methods: (string | Method)[]) - constructor(classFunction: { new(): any }) - constructor(classFunction: { new(): any }, entity: object) - constructor(classFunction: { new(): any }, entity: object, method: string) - constructor(classFunction: { new(): any }, entity: object, method: Method) - constructor(classFunction: { new(): any }, entity: object, methods: (string | Method)[]) - constructor(classFunction: { new(): any }, method: string) - constructor(classFunction: { new(): any }, method: Method) - constructor(classFunction: { new(): any }, methods: (string | Method)[]) - - constructor(arg1?: any, arg2?: any, arg3?: any) { - super(arg1, arg2, arg3) - } -} \ No newline at end of file diff --git a/src/domain/change/ChangeLogic.ts b/src/domain/change/ChangeLogic.ts deleted file mode 100644 index 571eee3..0000000 --- a/src/domain/change/ChangeLogic.ts +++ /dev/null @@ -1,60 +0,0 @@ -import { Result } from 'coderitter-api-remote-method-call' -import { Criteria } from 'knight-criteria' -import { Orm } from 'knight-orm' -import { PgTransaction } from 'knight-pg-transaction' -import { EntitiesResult, EntityResult } from '../api' -import { txQuery } from '../txQuery' -import { Log } from 'knight-log' -import Change from './Change' -import { ChangeValidator } from './validators' - -let log = new Log('ChangeLogic.ts') - -export default class ChangeLogic { - - orm!: Orm - - async store(change: Change, tx: PgTransaction): Promise> { - let l = log.mt('store') - l.param('change', change) - - return tx.runInTransaction(async () => { - let validator = new ChangeValidator() - let misfits = await validator.validate(change) - l.dev('misfits', misfits) - - if (misfits.length > 0) { - await tx.rollback() - return Result.misfits(misfits) as any - } - - let createdChange = await this.orm.store(txQuery(tx), Change, change) - - return new EntityResult(createdChange) - }) - } - - async read(criteria: Criteria = {}, tx: PgTransaction): Promise> { - let l = log.mt('read') - l.param('criteria', criteria) - - return tx.runInTransaction(async () => { - let changes: Change[] = await this.orm.load(txQuery(tx), Change, criteria) - - l.dev('changes', changes) - return new EntitiesResult(changes) - }) - } - - async latestVersion(tx: PgTransaction): Promise { - let l = log.mt('latestVersion') - - return tx.runInTransaction(async () => { - let dbResult = await tx.query('SELECT max(version) FROM change') - l.dev('dbResult.rows', dbResult.rows) - let latestVersion = dbResult.rows[0].max === null ? undefined : dbResult.rows[0].max - l.dev('latestVersion', latestVersion) - return latestVersion || 0 - }) - } -} \ No newline at end of file diff --git a/src/domain/change/validators.ts b/src/domain/change/validators.ts deleted file mode 100644 index 480ad01..0000000 --- a/src/domain/change/validators.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Absent, Enum, Required, TypeOf, Validator } from 'knight-validation' - -export class ChangeValidator extends Validator { - - constructor() { - super() - - this.add('version', new Absent) - - this.add('entityName', new Required) - this.add('entityName', new TypeOf('string')) - this.add('entityName', new Enum()) - - this.add('method', new Required) - this.add('method', new TypeOf('object')) - - this.add('entity', new Required) - this.add('entity', new TypeOf('object')) - } -} \ No newline at end of file From f6061fadaa3ddba9e258a7448595a27aac0261bd Mon Sep 17 00:00:00 2001 From: Luisa Date: Tue, 1 Mar 2022 07:52:07 +0100 Subject: [PATCH 2/2] Remove ws package, update knight orm and knight change package --- package-lock.json | 76 +++++++++++------------------------------------ package.json | 8 ++--- src/Services.ts | 15 ---------- 3 files changed, 20 insertions(+), 79 deletions(-) diff --git a/package-lock.json b/package-lock.json index 218685e..ab33301 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,19 +9,17 @@ "version": "0.0.0", "dependencies": { "@types/pg": "^7.14.11", - "@types/ws": "^6.0.4", "coderitter-api-remote-method-api": "^6.0.0", "coderitter-api-remote-method-call": "^4.0.1", - "knight-change": "^1.0.0", + "knight-change": "^2.0.0", "knight-criteria": "^2.0.7", "knight-json": "^1.0.1", "knight-log": "^1.0.6", - "knight-orm": "^0.3.1", + "knight-orm": "^0.4.0", "knight-pg-migration": "^1.0.0", "knight-pg-transaction": "^1.0.3", "knight-validation": "^1.0.0", - "pg": "^8.5.1", - "ws": "^7.4.5" + "pg": "^8.5.1" }, "devDependencies": { "@types/chai": "^4.2.14", @@ -152,14 +150,6 @@ "pg-types": "^2.2.0" } }, - "node_modules/@types/ws": { - "version": "6.0.4", - "resolved": "https://registry.npmjs.org/@types/ws/-/ws-6.0.4.tgz", - "integrity": "sha512-PpPrX7SZW9re6+Ha8ojZG4Se8AZXgf0GK6zmfqEuCsY49LFDNXO3SByp44X3dFEqtB73lkCDAdUazhAjVPiNwg==", - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@typescript-eslint/eslint-plugin": { "version": "5.9.1", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.9.1.tgz", @@ -1374,9 +1364,9 @@ "dev": true }, "node_modules/knight-change": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/knight-change/-/knight-change-1.0.0.tgz", - "integrity": "sha512-IaHjegQWKU/dGvLT75I/nApXiOz01bHaM7c4v8DtSJ+ZaW+BYab2zk5joK2f0EF5I8GA4bWk/okAy1aAiaMonw==" + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/knight-change/-/knight-change-2.0.0.tgz", + "integrity": "sha512-gaje+vqJ3DSDEV0KkqqDrXCmNtxMXO7a3PDgIK6BJWYCc/X9AFodCIqJbn3EyUuIkDHHF1nF36OZp2dtmmh9eQ==" }, "node_modules/knight-criteria": { "version": "2.0.7", @@ -1405,10 +1395,11 @@ "integrity": "sha512-scN0hAWyLVAvLR9AyW7HoFF5sJZglyBsbPuHO4fv7JRvfmPBMfp1ozWqOf/e4wwPNxezBZXRfWzMb6iFLgEVRA==" }, "node_modules/knight-orm": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/knight-orm/-/knight-orm-0.3.2.tgz", - "integrity": "sha512-wyVNUAfhywjLI35TVL+N1/K10lScOogK3zXbPUxMF9TAItVPDQ1qZygY3eWM3xCLiVrFy3ZE/mbuHqlIm8iPjQ==", + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/knight-orm/-/knight-orm-0.4.0.tgz", + "integrity": "sha512-5IRSyQDcdZ5gWLgSlGheSOlq/oa6k93KecVeWSQA3qiVdzOqS1toxd2ntW7NlgEX6K+TGDEkgMIudKjvEMSeqg==", "dependencies": { + "knight-change": "^2.0.0", "knight-criteria": "^2.0.7", "knight-log": "^1.0.6", "knight-sql": "^2.2.1" @@ -2350,26 +2341,6 @@ "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, - "node_modules/ws": { - "version": "7.5.6", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.6.tgz", - "integrity": "sha512-6GLgCqo2cy2A2rjCNFlxQS6ZljG/coZfZXclldI8FB/1G3CCI36Zd8xy2HrFVACi8tfk5XrgLQEk+P0Tnz9UcA==", - "engines": { - "node": ">=8.3.0" - }, - "peerDependencies": { - "bufferutil": "^4.0.1", - "utf-8-validate": "^5.0.2" - }, - "peerDependenciesMeta": { - "bufferutil": { - "optional": true - }, - "utf-8-validate": { - "optional": true - } - } - }, "node_modules/xtend": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", @@ -2553,14 +2524,6 @@ "pg-types": "^2.2.0" } }, - "@types/ws": { - "version": "6.0.4", - "resolved": "https://registry.npmjs.org/@types/ws/-/ws-6.0.4.tgz", - "integrity": "sha512-PpPrX7SZW9re6+Ha8ojZG4Se8AZXgf0GK6zmfqEuCsY49LFDNXO3SByp44X3dFEqtB73lkCDAdUazhAjVPiNwg==", - "requires": { - "@types/node": "*" - } - }, "@typescript-eslint/eslint-plugin": { "version": "5.9.1", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.9.1.tgz", @@ -3420,9 +3383,9 @@ "dev": true }, "knight-change": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/knight-change/-/knight-change-1.0.0.tgz", - "integrity": "sha512-IaHjegQWKU/dGvLT75I/nApXiOz01bHaM7c4v8DtSJ+ZaW+BYab2zk5joK2f0EF5I8GA4bWk/okAy1aAiaMonw==" + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/knight-change/-/knight-change-2.0.0.tgz", + "integrity": "sha512-gaje+vqJ3DSDEV0KkqqDrXCmNtxMXO7a3PDgIK6BJWYCc/X9AFodCIqJbn3EyUuIkDHHF1nF36OZp2dtmmh9eQ==" }, "knight-criteria": { "version": "2.0.7", @@ -3453,10 +3416,11 @@ } }, "knight-orm": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/knight-orm/-/knight-orm-0.3.2.tgz", - "integrity": "sha512-wyVNUAfhywjLI35TVL+N1/K10lScOogK3zXbPUxMF9TAItVPDQ1qZygY3eWM3xCLiVrFy3ZE/mbuHqlIm8iPjQ==", + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/knight-orm/-/knight-orm-0.4.0.tgz", + "integrity": "sha512-5IRSyQDcdZ5gWLgSlGheSOlq/oa6k93KecVeWSQA3qiVdzOqS1toxd2ntW7NlgEX6K+TGDEkgMIudKjvEMSeqg==", "requires": { + "knight-change": "^2.0.0", "knight-criteria": "^2.0.7", "knight-log": "^1.0.6", "knight-sql": "^2.2.1" @@ -4103,12 +4067,6 @@ "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, - "ws": { - "version": "7.5.6", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.6.tgz", - "integrity": "sha512-6GLgCqo2cy2A2rjCNFlxQS6ZljG/coZfZXclldI8FB/1G3CCI36Zd8xy2HrFVACi8tfk5XrgLQEk+P0Tnz9UcA==", - "requires": {} - }, "xtend": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", diff --git a/package.json b/package.json index ec8b5ba..5b3bb2d 100644 --- a/package.json +++ b/package.json @@ -13,19 +13,17 @@ }, "dependencies": { "@types/pg": "^7.14.11", - "@types/ws": "^6.0.4", "coderitter-api-remote-method-api": "^6.0.0", "coderitter-api-remote-method-call": "^4.0.1", - "knight-change": "^1.0.0", + "knight-change": "^2.0.0", "knight-criteria": "^2.0.7", "knight-json": "^1.0.1", "knight-log": "^1.0.6", - "knight-orm": "^0.3.1", + "knight-orm": "^0.4.0", "knight-pg-migration": "^1.0.0", "knight-pg-transaction": "^1.0.3", "knight-validation": "^1.0.0", - "pg": "^8.5.1", - "ws": "^7.4.5" + "pg": "^8.5.1" }, "devDependencies": { "@types/chai": "^4.2.14", diff --git a/src/Services.ts b/src/Services.ts index 1447a13..b2f8241 100644 --- a/src/Services.ts +++ b/src/Services.ts @@ -1,7 +1,6 @@ import http from 'http' import { Pool } from 'pg' import { Log } from 'knight-log' -import WebSocket from 'ws' import ApiV1 from './api/ApiV1' import HttpApi from './api/HttpApi' import { getConfigByArgvOrEnvOrDefault, test } from './config' @@ -30,7 +29,6 @@ export default class Services { pool!: Pool httpServer!: http.Server - webSocketServer!: WebSocket.Server apiV1 = new ApiV1 httpApi!: HttpApi @@ -62,14 +60,6 @@ export default class Services { async startServer() { // HTTP Server this.httpServer = http.createServer() - - // WebSocket Server - this.webSocketServer = new WebSocket.Server({ - server: this.httpServer - }, () => { - let address = this.webSocketServer.address() as any - log.admin('WebSocket server running at ' + address.address + ':' + address.port + ' - ' + address.family) - }) } startApis() { @@ -98,11 +88,6 @@ export default class Services { log.admin('Stopped HTTP server') } - if (this.webSocketServer) { - this.webSocketServer.close() - log.admin('Stopped WebSocket server') - } - Log.watcher?.close() }