-
Notifications
You must be signed in to change notification settings - Fork 2
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
10 naming #25
base: main
Are you sure you want to change the base?
Conversation
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.
Looks good overall, I'd suggest one naming convention change though
src/resource/event/event.service.ts
Outdated
@@ -42,7 +42,7 @@ export class EventService { | |||
return event; | |||
} | |||
|
|||
async fetchUserEvents(userId: number): Promise<ReturnEventDTO[]> { | |||
async fetchUser(userId: number): Promise<ReturnEventDTO[]> { |
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.
Wrong naming convention in my opinion, service method returns Events, not a User, I think something like "fetchByUser" would be more descriptive
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.
I agree
src/resource/note/note.service.ts
Outdated
@@ -12,22 +12,22 @@ export class NoteService { | |||
private noteRepository: Repository<NoteEntity>, | |||
) {} | |||
|
|||
async fetchUserNotes(user: UserEntity) { | |||
async fetchUser(user: UserEntity): Promise<NoteDTO[]> { |
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.
Same here
src/resource/task/task.service.ts
Outdated
return await this.taskRepository.findOne({ | ||
where: { id, user }, | ||
}); | ||
} | ||
|
||
async getAllUserTasks(user: UserEntity): Promise<ReturnTaskDTO[]> { | ||
async fetchUser(user: UserEntity): Promise<ReturnTaskDTO[]> { |
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.
And here
The requested change (renaming
|
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.
Looks good to me
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.
Small changes, overall good job
@@ -54,7 +54,7 @@ export class EventController { | |||
async getUserEvents( | |||
@GetUser('id') userId: number, | |||
): Promise<ReturnEventDTO[]> { | |||
return await this.eventService.fetchUserEvents(userId); | |||
return await this.eventService.fetchByUser(userId); |
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.
And that one is clear, cool
@@ -74,7 +74,7 @@ export class EventController { | |||
@Get(':id') | |||
@GetEventByIdApi() | |||
async getEventById(@Param('id') eventId: number): Promise<ReturnEventDTO> { | |||
return await this.eventService.fetchById(eventId); | |||
return await this.eventService.fetch(eventId); |
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.
fetchById because we don't know if we fetch all or not.
You could use [serviceName].fetchAll or fetchOne and albo fetchById
} | ||
|
||
@HttpCode(HttpStatus.NO_CONTENT) | ||
@Delete('exceptions/:id') | ||
@DeleteExceptionApi() | ||
async deleteException(@Param('id') exceptionId: number): Promise<void> { | ||
await this.eventService.removeExceptionById(exceptionId); | ||
await this.eventService.deleteException(exceptionId); |
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.
deleteException in this case is clear, because we know that we want to delete one so it is obvious that we need for example id
src/resource/note/note.controller.ts
Outdated
EditNoteApi as EditNoteApi, | ||
GetUserNotesApi as GetUserNotesApi, |
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.
Wait, why there is 'as'?
@GetUserNotesApi() | ||
getUserNotes(@GetUser() user: UserEntity): Promise<NoteDTO[]> { | ||
return this.notesService.fetchByUser(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.
I forgot to mention that if TypeScript infer type properly if you hover your mouse on function then you don't need to declare type explicitly
src/resource/task/task.controller.ts
Outdated
GetUserTasksApi as GetUserTasksApi, | ||
GetTaskByIdApi as GetTaskbyIdApi, |
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.
Again unnecessary 'as'
Both changes have been implemented:
|
GET
<resource>
getUser<Resource>s
fetchUser
GET
<resource>/<id>
get<Resource>ById
fetch
POST
<resource>
add<Resource>
add
PATCH
<resource>/<id>
edit<Resource>
edit
DELETE
<resource>/<id>
delete<Resource>
delete