diff --git a/src/adapters/web-socket-adapter.ts b/src/adapters/web-socket-adapter.ts index 02a312ce..e7c13f6e 100644 --- a/src/adapters/web-socket-adapter.ts +++ b/src/adapters/web-socket-adapter.ts @@ -120,7 +120,7 @@ export class WebSocketAdapter extends EventEmitter implements IWebSocketAdapter private async onClientMessage(raw: Buffer) { let abort: () => void try { - const message = attemptValidation(messageSchema)(JSON.parse(raw.toString('utf-8'))) + const message = attemptValidation(messageSchema)(JSON.parse(raw.toString('utf8'))) const messageHandler = this.createMessageHandler([message, this]) as IMessageHandler & IAbortable if (typeof messageHandler.abort === 'function') { diff --git a/src/factories/worker-factory.ts b/src/factories/worker-factory.ts index 702fe824..c3f8dd8b 100644 --- a/src/factories/worker-factory.ts +++ b/src/factories/worker-factory.ts @@ -13,6 +13,7 @@ export const workerFactory = (): AppWorker => { const dbClient = getDbClient() const eventRepository = new EventRepository(dbClient) + // deepcode ignore HttpToHttps: const server = http.createServer() const webSocketServer = new WebSocketServer({ server, diff --git a/src/repositories/event-repository.ts b/src/repositories/event-repository.ts index 21cb94a0..76410027 100644 --- a/src/repositories/event-repository.ts +++ b/src/repositories/event-repository.ts @@ -158,7 +158,7 @@ export class EventRepository implements IEventRepository { } public async create(event: Event): Promise { - return this.insert(event).then(prop('rowCount') as () => number) + return this.insert(event).then(prop('rowCount') as () => number, () => 0) } private insert(event: Event) { diff --git a/test/integration/features/helpers.ts b/test/integration/features/helpers.ts index 80212ef3..b27b382d 100644 --- a/test/integration/features/helpers.ts +++ b/test/integration/features/helpers.ts @@ -97,7 +97,7 @@ export async function waitForEOSE(ws: WebSocket, subscription: string): Promise< ws.once('error', onError) function onMessage(raw: RawData) { - const message = JSON.parse(raw.toString('utf-8')) + const message = JSON.parse(raw.toString('utf8')) if (message[0] === MessageType.EOSE && message[1] === subscription) { resolve() cleanup() @@ -139,7 +139,7 @@ export async function waitForNextEvent(ws: WebSocket, subscription: string): Pro } function onMessage(raw: RawData) { - const message = JSON.parse(raw.toString('utf-8')) + const message = JSON.parse(raw.toString('utf8')) if (message[0] === MessageType.EVENT && message[1] === subscription) { resolve(message[2]) cleanup() @@ -172,7 +172,7 @@ export async function waitForEventCount( cleanup() } function onMessage(raw: RawData) { - const message = JSON.parse(raw.toString('utf-8')) + const message = JSON.parse(raw.toString('utf8')) if (message[0] === MessageType.EVENT && message[1] === subscription) { events.push(message[2]) if (!eose && events.length === count) { @@ -213,7 +213,7 @@ export async function waitForNotice(ws: WebSocket): Promise { ws.once('error', onError) function onMessage(raw: RawData) { - const message = JSON.parse(raw.toString('utf-8')) + const message = JSON.parse(raw.toString('utf8')) if (message[0] === MessageType.NOTICE) { resolve(message[1]) cleanup() diff --git a/test/unit/factories/websocket-adapter-factory.spec.ts b/test/unit/factories/websocket-adapter-factory.spec.ts index 56984259..c654902b 100644 --- a/test/unit/factories/websocket-adapter-factory.spec.ts +++ b/test/unit/factories/websocket-adapter-factory.spec.ts @@ -28,7 +28,7 @@ describe('webSocketAdapterFactory', () => { onStub.returns(client) const request: IncomingMessage = { headers: { - 'sec-websocket-key': Buffer.from('key', 'utf-8').toString('base64'), + 'sec-websocket-key': Buffer.from('key', 'utf8').toString('base64'), }, } as any const webSocketServerAdapter: IWebSocketServerAdapter = {} as any