Skip to content

Commit

Permalink
return type fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
e11sy committed Oct 21, 2023
1 parent d51c891 commit 3e8b497
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
11 changes: 3 additions & 8 deletions src/presentation/http/router/note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const NoteRouter: FastifyPluginCallback<NoteRouterOptions> = (fastify, opts, don
notePublicId : NotePublicId;
},
Reply: {
deletedFlag : number
deletedFlag : boolean
},
}>('/:notePublicId', {
schema: {
Expand All @@ -110,17 +110,12 @@ const NoteRouter: FastifyPluginCallback<NoteRouterOptions> = (fastify, opts, don
* @todo Check user access right
*/
const noteId = request.note?.id as number;
const affectedRows = await noteService.deleteNoteById(noteId);
const deletedFlag = await noteService.deleteNoteById(noteId);

/**
* Check if note does not exist
*/
if (affectedRows === false) {
return reply.send({ deletedFlag: 0});
}
else {
return reply.send({ deletedFlag: 17 }/**{ deletedFlag: noteId }*/);
};
return reply.send({ deletedFlag : deletedFlag});
});

/**
Expand Down
2 changes: 1 addition & 1 deletion src/repository/storage/postgres/orm/sequelize/note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export default class NoteSequelizeStorage {
/**
* If note not found, return null
*/
return affectedRows === 1;
return affectedRows > 0;
}

/**
Expand Down

0 comments on commit 3e8b497

Please sign in to comment.