diff --git a/src/domain/entities/noteList.ts b/src/domain/entities/noteList.ts index 17dacf6a..61d3da76 100644 --- a/src/domain/entities/noteList.ts +++ b/src/domain/entities/noteList.ts @@ -1,5 +1,8 @@ import type { Note } from '@domain/entities/note.js'; +/** + * Note list entity + */ export type NoteList = { items: Note[]; }; diff --git a/src/domain/service/noteList.ts b/src/domain/service/noteList.ts index 5ab929d1..d806abd0 100644 --- a/src/domain/service/noteList.ts +++ b/src/domain/service/noteList.ts @@ -17,12 +17,12 @@ export default class NoteListService { } /** - * Gets note list by creator id + * Returns note list by creator id * * @param id - note creator id - * @returns { Promise } note + * @returns { Promise } note */ - public async getNoteListByCreatorId(id: number): Promise { + public async getNoteListByCreatorId(id: number): Promise { return await this.repository.getNoteListByCreatorId(id); } } diff --git a/src/presentation/http/router/noteList.ts b/src/presentation/http/router/noteList.ts index 9f44ddab..6752ba97 100644 --- a/src/presentation/http/router/noteList.ts +++ b/src/presentation/http/router/noteList.ts @@ -38,18 +38,6 @@ const NoteListRouter: FastifyPluginCallback = (fastify, o const { userId } = request; const noteList = await noteListService.getNoteListByCreatorId(userId as number); - /** - * Check if note list does not exist - */ - if (!noteList) { - const response: ErrorResponse = { - code: StatusCodes.NOT_FOUND, - message: 'Note list not found', - }; - - return reply.send(response); - } - return reply.send(noteList); }); diff --git a/src/repository/note.repository.ts b/src/repository/note.repository.ts index 81965061..3e407413 100644 --- a/src/repository/note.repository.ts +++ b/src/repository/note.repository.ts @@ -74,9 +74,9 @@ export default class NoteRepository { * Gets note list by creator id * * @param id - note creator id - * @returns { Promise } note + * @returns { Promise } note */ - public async getNoteListByCreatorId(id: number): Promise { + public async getNoteListByCreatorId(id: number): Promise { return await this.storage.getNoteListByCreatorId(id); } } diff --git a/src/repository/storage/postgres/orm/sequelize/note.ts b/src/repository/storage/postgres/orm/sequelize/note.ts index 0bedc055..98ca577b 100644 --- a/src/repository/storage/postgres/orm/sequelize/note.ts +++ b/src/repository/storage/postgres/orm/sequelize/note.ts @@ -190,19 +190,15 @@ export default class NoteSequelizeStorage { * Gets note list by creator id * * @param creatorId - note creator id - * @returns { Promise } note + * @returns { Promise } note */ - public async getNoteListByCreatorId(creatorId: number): Promise { + public async getNoteListByCreatorId(creatorId: number): Promise { const noteList = await this.model.findAll({ where: { creatorId, }, }); - if (noteList.length === 0) { - return null; - } - return { items: noteList, };