-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/backend/strict null check #279
Merged
+162
−105
Merged
Changes from 5 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
86d8e98
[backend] Enable strictNullChecks in tsconfig.json
usatie 00c8a15
[backend] Fix handleDisconnect to handle null user
usatie f8cd939
[backend] Fix MessageEntity constructor by strict null check
usatie a763fe3
[backend] Fix WsPublicUserEntity constructor by using the correct type
usatie f4f47c5
[backend] Fix match request handlers
usatie 702ec41
[backend] Fix UpdateUserOnRoomDto to not use PartialType
usatie 9b3678c
[backend] Fix RoomEntity password type to be nullable
usatie ba7f74a
[backend] Fix UserEntity password type to be nullable
usatie 0959b62
[backend] Fix PublicUserEntity password type to be nullable
usatie 3400425
[backend] Fix mute and ban services to use findUniqueOrThrow
usatie 85a2a0a
[backend] Fix strict null check in enter-room.guard.ts
usatie c478ea3
[backend] Fix strict null check for events.gateway.ts
usatie 6e5ff80
[backend] Fix strict null check in auth service
usatie d64033f
[backend] Fix strict null check in seed.ts
usatie 5751add
[backend] Fix strict null check in main.ts
usatie 8efb0c4
[backend] Fix strict null check in events.gateway.ts
usatie 53624f0
[backend] Fix WsPublicUserEntity constructor
usatie 7b17a76
[backend] Remove CreateUserOnRoomDto (which is not used)
usatie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
export class PublicUserEntity { | ||
constructor(partial: Partial<PublicUserEntity>) { | ||
this.id = partial.id; | ||
this.name = partial.name; | ||
this.avatarURL = partial.avatarURL; | ||
export class WsPublicUserEntity { | ||
constructor(user: WsPublicUserEntity) { | ||
this.id = user.id; | ||
this.name = user.name; | ||
this.avatarURL = user.avatarURL; | ||
} | ||
id: number; | ||
name: string; | ||
avatarURL?: string; | ||
avatarURL: string | null; | ||
} | ||
|
||
export class MessageEntity { | ||
constructor(partial: Partial<MessageEntity>, user: PublicUserEntity) { | ||
this.content = partial.content; | ||
this.roomId = partial.roomId; | ||
constructor(message: Omit<MessageEntity, 'user'>, user: WsPublicUserEntity) { | ||
this.content = message.content; | ||
this.roomId = message.roomId; | ||
this.user = user; | ||
} | ||
content: string; | ||
roomId: number; | ||
user: PublicUserEntity; | ||
user: WsPublicUserEntity; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The constructor of
WsPublicUserEntity
takes an instance of its own class as a parameter, which seems unusual for typical use cases. This pattern might be intended for cloning instances, but if that's not the case, it could lead to confusion or misuse. Consider revising the constructor's parameter to match the intended use case, such as accepting raw user data instead.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
確かに。まー引数にはPrismaのUserを取っておくか。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@usatie: 確かに、Prismaの
User
型をコンストラクタの引数として使用する提案は、初期のコメントで提起された懸念に直接対処します。この変更により、コンストラクタの目的がより明確になり、データベースからの生データを使ってエンティティを初期化するという一般的な使用例に合致します。この方向での修正がコードの明確性と使いやすさを向上させるでしょう。もし追加でサポートや説明が必要であれば、お知らせください。