From 060d31bd2378c11be415aa1db36c0f347566b2bd Mon Sep 17 00:00:00 2001 From: davwas Date: Mon, 15 Jan 2024 10:13:27 +0100 Subject: [PATCH] fix issues after merge --- apps/server/src/modules/tldraw/controller/tldraw.ws.ts | 2 +- .../modules/tldraw/entities/tldraw-drawing.entity.spec.ts | 6 ------ .../src/modules/tldraw/entities/tldraw-drawing.entity.ts | 4 +--- .../tldraw/loggable/websocket-close-error.loggable.spec.ts | 2 +- .../tldraw/loggable/websocket-close-error.loggable.ts | 2 +- apps/server/src/modules/tldraw/service/tldraw.ws.service.ts | 4 +++- apps/server/src/modules/tldraw/tldraw.module.ts | 2 +- 7 files changed, 8 insertions(+), 14 deletions(-) diff --git a/apps/server/src/modules/tldraw/controller/tldraw.ws.ts b/apps/server/src/modules/tldraw/controller/tldraw.ws.ts index 33372cbfff9..cd406673a1f 100644 --- a/apps/server/src/modules/tldraw/controller/tldraw.ws.ts +++ b/apps/server/src/modules/tldraw/controller/tldraw.ws.ts @@ -82,6 +82,6 @@ export class TldrawWs implements OnGatewayInit, OnGatewayConnection { private closeClientAndLogError(client: WebSocket, code: WsCloseCodeEnum, data: string, err: Error): void { client.close(code, data); - this.logger.warning(new WebsocketCloseErrorLoggable(err, `(${code}) ${data}`)); + this.logger.warning(new WebsocketCloseErrorLoggable(`(${code}) ${data}`, err)); } } diff --git a/apps/server/src/modules/tldraw/entities/tldraw-drawing.entity.spec.ts b/apps/server/src/modules/tldraw/entities/tldraw-drawing.entity.spec.ts index 05c50254a72..2698056a0ef 100644 --- a/apps/server/src/modules/tldraw/entities/tldraw-drawing.entity.spec.ts +++ b/apps/server/src/modules/tldraw/entities/tldraw-drawing.entity.spec.ts @@ -14,12 +14,6 @@ describe('tldraw entity', () => { expect(tldraw).toBeInstanceOf(TldrawDrawing); }); - - it('should throw with empty docName', () => { - const call = () => tldrawEntityFactory.build({ docName: '' }); - - expect(call).toThrow(); - }); }); }); }); diff --git a/apps/server/src/modules/tldraw/entities/tldraw-drawing.entity.ts b/apps/server/src/modules/tldraw/entities/tldraw-drawing.entity.ts index 0a245a42720..ea99deccb9e 100644 --- a/apps/server/src/modules/tldraw/entities/tldraw-drawing.entity.ts +++ b/apps/server/src/modules/tldraw/entities/tldraw-drawing.entity.ts @@ -1,6 +1,5 @@ import { Entity, Index, Property } from '@mikro-orm/core'; -import { BadRequestException } from '@nestjs/common'; -import { BaseEntity } from '@shared/domain/entity'; +import { BaseEntity } from '@shared/domain/entity/base.entity'; export interface TldrawDrawingProps { _id?: string; @@ -35,7 +34,6 @@ export class TldrawDrawing extends BaseEntity { constructor(props: TldrawDrawingProps) { super(); - if (!props.docName) throw new BadRequestException('Tldraw element should have name.'); this.docName = props.docName; this.version = props.version; this.value = props.value; diff --git a/apps/server/src/modules/tldraw/loggable/websocket-close-error.loggable.spec.ts b/apps/server/src/modules/tldraw/loggable/websocket-close-error.loggable.spec.ts index b14fb64c1e7..6a3efd43002 100644 --- a/apps/server/src/modules/tldraw/loggable/websocket-close-error.loggable.spec.ts +++ b/apps/server/src/modules/tldraw/loggable/websocket-close-error.loggable.spec.ts @@ -6,7 +6,7 @@ describe('WebsocketCloseErrorLoggable', () => { const error = new Error('test'); const errorMessage = 'message'; - const loggable = new WebsocketCloseErrorLoggable(error, errorMessage); + const loggable = new WebsocketCloseErrorLoggable(errorMessage, error); return { loggable, error, errorMessage }; }; diff --git a/apps/server/src/modules/tldraw/loggable/websocket-close-error.loggable.ts b/apps/server/src/modules/tldraw/loggable/websocket-close-error.loggable.ts index 6e395f5fc17..081e853abc4 100644 --- a/apps/server/src/modules/tldraw/loggable/websocket-close-error.loggable.ts +++ b/apps/server/src/modules/tldraw/loggable/websocket-close-error.loggable.ts @@ -1,7 +1,7 @@ import { ErrorLogMessage, Loggable, LogMessage, ValidationErrorLogMessage } from '@src/core/logger'; export class WebsocketCloseErrorLoggable implements Loggable { - constructor(private readonly error: Error, private readonly message: string) {} + constructor(private readonly message: string, private readonly error: Error) {} getLogMessage(): LogMessage | ErrorLogMessage | ValidationErrorLogMessage { return { diff --git a/apps/server/src/modules/tldraw/service/tldraw.ws.service.ts b/apps/server/src/modules/tldraw/service/tldraw.ws.service.ts index 2515f4f3f72..6f2da7174be 100644 --- a/apps/server/src/modules/tldraw/service/tldraw.ws.service.ts +++ b/apps/server/src/modules/tldraw/service/tldraw.ws.service.ts @@ -89,7 +89,9 @@ export class TldrawWsService { try { ws.close(); } catch (err) { - this.logger.warning(new WebsocketCloseErrorLoggable(err as Error)); + this.logger.warning( + new WebsocketCloseErrorLoggable('Error while closing websocket, it may already be closed', err as Error) + ); } } diff --git a/apps/server/src/modules/tldraw/tldraw.module.ts b/apps/server/src/modules/tldraw/tldraw.module.ts index 521607c4ea1..5c43cfb5780 100644 --- a/apps/server/src/modules/tldraw/tldraw.module.ts +++ b/apps/server/src/modules/tldraw/tldraw.module.ts @@ -10,7 +10,7 @@ import { Dictionary, IPrimaryKey } from '@mikro-orm/core'; import { AuthorizationModule } from '@modules/authorization'; import { config } from './config'; import { TldrawDrawing } from './entities'; -import { TldrawController } from './controller/tldraw.controller'; +import { TldrawController } from './controller'; import { TldrawService } from './service'; import { TldrawBoardRepo, TldrawRepo, YMongodb } from './repo';