Skip to content

Conversation

@shvkhzod
Copy link
Member

Working on event-bus, I tried to keep it in domain layer only and cover noteVisits and noteSettings.
But had to use noteSettings directly from presentation layer in getting the role of user to determine whether he can edit the note or not.
Other than that, it is fine.

@github-actions
Copy link

Coverage Report

Status Category Percentage Covered / Total
🟢 Lines 86.09% (🎯 80%)
⬇️ -0.08%
7471 / 8678
🟢 Statements 86.09% (🎯 80%)
⬇️ -0.08%
7471 / 8678
🔴 Functions 78.38% (🎯 80%)
⬇️ -0.89%
243 / 310
🟢 Branches 85.48% (🎯 80%)
⬇️ -0.20%
371 / 434
File Coverage
File Stmts % Branch % Funcs % Lines Uncovered Lines
Changed Files
src/domain/event-bus/index.ts 100% 100% 100% 100%
src/domain/event-bus/events/noteAddedEvent.ts 100% 100% 100% 100%
src/domain/event-bus/events/noteVisitedEvent.ts 100% 100% 100% 100%
src/domain/service/note.ts 95.67% 79.16% 100% 95.67% 69-70, 101-102, 108-109, 124-125, 148-149
src/domain/service/noteSettings.ts 97.34% 88% 100% 97.34% 51-52, 132-133, 209-210
src/domain/service/noteVisits.ts 88.4% 66.66% 50% 88.4% 36-37, 46-47, 58-59, 67-68
src/presentation/http/router/note.ts 97.69% 80.95% 100% 97.69% 130-131, 444-445, 461-467
Generated in workflow #686

* Listen to the note related events
*/
EventBus.getInstance().addEventListener(NOTE_ADDED_EVENT_NAME, async (event) => {
const { noteId, userId } = (event as CustomEvent<{ noteId: number; userId: number }>).detail;
Copy link
Member

@neSpecc neSpecc Apr 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we get rid of this casting? Maybe we can declare EventMap. Example:

https://github.com/codex-team/notes.web/blob/main/src/domain/event-bus/index.ts#L14-L29

Comment on lines +15 to +16
super(NOTE_VISITED_EVENT_NAME, { detail: { noteId,
userId } });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bad line break

Suggested change
super(NOTE_VISITED_EVENT_NAME, { detail: { noteId,
userId } });
super(NOTE_VISITED_EVENT_NAME, {
detail: {
noteId,
userId
}
});

/**
* Note visited event
*/
export class NoteVisitedEvent extends CustomEvent<{ noteId: number; userId: number }> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export class NoteVisitedEvent extends CustomEvent<{ noteId: number; userId: number }> {
export class NoteVisitedEvent extends CustomEvent<{ noteId: Note['id']; userId: User['id'] }> {

@neSpecc neSpecc marked this pull request as ready for review April 25, 2024 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants