Skip to content

Endpoint Notifications ​

Trang này liệt kê 5 endpoint thông báo trong notification.api.ts: danh sách, số chưa đọc, đánh dấu đã đọc và xóa. Thông báo mới đến theo thời gian thực qua Socket.IO, không qua các endpoint này; xem Giao tiếp thời gian thực.

Vì sao có tag riêng cho từng thông báo ​

Chuông thông báo cần cập nhật số chưa đọc và danh sách ngay khi người dùng đánh dấu đã đọc hay xóa. Vì vậy các endpoint dùng tag có id (LIST, UNREAD_COUNT, mã từng thông báo) thay vì một tag chung, để chỉ làm mới đúng phần cần thiết.

Bảng endpoint ​

Hook RTK QueryMethod và pathTham số frontend gửiCache tagNơi dùng
useGetNotificationsQueryGET /notifications?page=..&limit=..page (1), limit (10)Cung cấp LIST, LIST-<page>-<limit> và từng { Notification, id }notification-bell.tsx, profile/pages/notifications-page.tsx
useGetUnreadCountQueryGET /notifications/unread-countKhôngCung cấp UNREAD_COUNThooks/use-notification.ts
useMarkAsReadMutationPATCH /notifications/:id/readidLàm mất hiệu lực { Notification, id }, LIST, UNREAD_COUNThooks/use-notification.ts
useMarkAllAsReadMutationPATCH /notifications/read-allKhôngLIST, UNREAD_COUNThooks/use-notification.ts
useDeleteNotificationMutationDELETE /notifications/:idid{ Notification, id }, LIST, UNREAD_COUNThooks/use-notification.ts

Đối chiếu với backend ​

Cả 5 route có trong notifications.controller.ts; không route nào khai báo giới hạn vai trò, nên mọi người dùng đã đăng nhập gọi được.

ĐiểmChi tiết
Tên field người nhậnSchema backend lưu userId; schema Zod ở frontend khai báo recipient bắt buộc. Chưa đối chiếu phản hồi thật nên chưa biết backend có đổi tên khi trả về hay không
Loại thông báoFrontend và backend cùng có hai loại: APPLICATION_STATUS_CHANGE, NEW_APPLICATION

Dữ liệu ​

Notification gồm _id, recipient, type, title, message, isRead, createdAt, updatedAt và data tùy chọn (resumeId, jobId, companyId, status). Chưa có trang model riêng cho thông báo; định nghĩa nằm ở notification.schema.ts.

Source code liên quan ​

Hợp đồng đầy đủ: API Notifications của backend và controller.

Đọc tiếp: Cache và invalidation, Giao tiếp thời gian thực, Endpoint Resumes.

Tài liệu kỹ thuật xây dựng theo chuẩn Documentation as Code