Skip to content

Commit fe6c8fe

Browse files
HaoNguyen-Ronimrim12
authored andcommitted
addd: Date parse for method PATCH sys_ notification
1 parent 6857866 commit fe6c8fe

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

server/api/users/[userId]/notifications/[notificationUId].patch.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ export default defineEventHandler(async (event) => {
99
const queryRestrict = { user_id: userId }
1010
const { updateNotificationById } = useNotificationCrud(queryRestrict)
1111

12-
const body = await readValidatedBody(event, createInsertSchema(sysNotificationTable).partial().parse)
12+
const body = await readBody(event)
1313

1414
if (body && body.read_at) {
1515
body.read_at = new Date(body.read_at)
1616
}
1717

18-
const data = await updateNotificationById(notificationUId, body)
18+
const validatedBody = createInsertSchema(sysNotificationTable).partial().parse(body)
19+
20+
const data = await updateNotificationById(notificationUId, validatedBody)
1921

2022
setResponseStatus(event, 200)
2123

0 commit comments

Comments
 (0)