Threads API v2
Completed v1.0.0

QA Project Documentation

Threads API v2 là backend mạng xã hội dùng Express, TypeScript, Prisma, MySQL, Redis, BullMQ, Cloudflare R2, Pusher và các dịch vụ AI. Tài liệu này liệt kê các module đã có route trong dự án, các endpoint cần kiểm thử, điều kiện xác thực và checklist hành vi cho QA.

Base path: /api/v1 · Swagger UI: /api/v1/docs · Route source: src/routes/index.ts

System Architecture Map

Frontend API Gateway Services Database Web App Mobile App API Gateway Auth Middleware Auth Health Users Upload Posts Search Circles Polls Messages Quests Museum AI Admin MySQL Redis R2 Storage Pinecone
MODULE 01

Authentication & Session

Completed

Module xác thực chịu trách nhiệm đăng ký, đăng nhập, refresh token, logout, xác minh email, quên mật khẩu và cập nhật hồ sơ cơ bản. QA cần kiểm tra kỹ định dạng email, username, độ dài mật khẩu, token hết hạn, token bị blacklist sau logout và các phản hồi khi thiếu Bearer token.

Registration & Login
Người dùng đăng ký bằng username, email, password và đăng nhập bằng email hoặc username để nhận token pair.
  • ✓ POST /api/v1/auth/register with valid body → 201 + success true + user data
  • ✓ POST /api/v1/auth/register with mismatched confirmPassword → 400 Validation failed
  • ✓ POST /api/v1/auth/login with valid login/password → 200 + token pair in data
  • ✓ POST /api/v1/auth/login with wrong password → 401 Invalid credentials
Token Lifecycle
Access token được kiểm tra qua middleware, refresh token được hash và dùng để tạo token pair mới.
  • ✓ POST /api/v1/auth/refresh-token with valid refresh token → 200 + new token pair
  • ✓ POST /api/v1/auth/logout with valid Bearer + refresh token → 200 Logout success
  • ✓ Reuse blacklisted access token after logout → 401 TOKEN_INVALID
  • ✓ Missing Authorization header on protected route → 401 TOKEN_INVALID
Email & Password Recovery
Luồng email xác minh và đặt lại mật khẩu dùng token, validate schema và queue gửi email nền.
  • ✓ POST /api/v1/auth/forgot-password with valid email → 200 Forgot password success
  • ✓ GET /api/v1/auth/reset-password/validate with valid token → 200 token validation result
  • ✓ POST /api/v1/auth/reset-password with password shorter than 8 → 400 Validation failed
  • ✓ POST /api/v1/auth/verify-email with empty token → 400 Validation failed
Availability & Profile
API kiểm tra email/username và API cập nhật profile hỗ trợ frontend validate dữ liệu trước khi submit.
  • ✓ POST /api/v1/auth/validate/email with valid email → 200 + availability result
  • ✓ POST /api/v1/auth/validate/username with invalid characters → 400 Validation failed
  • ✓ GET /api/v1/auth/me with valid Bearer → 200 + current user profile
  • ✓ POST /api/v1/auth/profile with bio over 500 chars → 400 Validation failed

API Endpoints

MethodEndpointDescriptionAuthStatus
POST/api/v1/auth/registerĐăng ký tài khoản mới, validate username/email/password và trả về dữ liệu user.NoDone
POST/api/v1/auth/loginĐăng nhập bằng email hoặc username, trả về token pair khi hợp lệ.NoDone
POST/api/v1/auth/forgot-passwordTạo yêu cầu quên mật khẩu và kích hoạt luồng email đặt lại mật khẩu.NoDone
POST/api/v1/auth/profileCập nhật hồ sơ người dùng hiện tại với name, bio, location, website hoặc avatar.BearerDone
POST/api/v1/auth/refresh-tokenLàm mới access token bằng refresh token hợp lệ.Refresh tokenDone
GET/api/v1/auth/meLấy thông tin người dùng từ Bearer token hiện tại.BearerDone
POST/api/v1/auth/logoutĐăng xuất, thu hồi refresh token và blacklist access token.Bearer + refresh tokenDone
POST/api/v1/auth/resend-verify-emailGửi lại email xác minh cho tài khoản đang đăng nhập.BearerDone
POST/api/v1/auth/verify-emailXác minh email bằng token trong body.NoDone
POST/api/v1/auth/validate/emailKiểm tra định dạng và trạng thái tồn tại của email.NoDone
POST/api/v1/auth/validate/usernameKiểm tra định dạng và trạng thái tồn tại của username.NoDone
GET/api/v1/auth/reset-password/validateKiểm tra token reset password qua query string.NoDone
POST/api/v1/auth/reset-passwordĐặt lại mật khẩu bằng email, token, password và confirmPassword.NoDone
MODULE 02

Platform Health & Docs

Completed

Module nền tảng cung cấp health check cho uptime monitoring và Swagger UI để QA rà soát contract API. Health endpoint trả về tên service, môi trường và timestamp; Swagger được mount trực tiếp dưới API gateway.

Health Probe
Endpoint kiểm tra tình trạng service dùng cho smoke test, deployment check và monitoring.
  • ✓ GET /api/v1/health → 200 Service is healthy
  • ✓ Response data includes service threads-api-v2, status ok, environment, timestamp
  • ✓ No Authorization header required for health checks
Swagger UI
Swagger UI được serve bởi `swagger-ui-express` để test thủ công các API đã khai báo trong code.
  • ✓ GET /api/v1/docs → Swagger UI loads without authentication
  • ✓ Swagger server list includes local and production base URLs
  • ✓ Tags include Auth, Post, User, Upload, Circle, Admin and integrations

API Endpoints

MethodEndpointDescriptionAuthStatus
GET/api/v1/healthTrả về trạng thái sống của service và metadata runtime.NoDone
GET/api/v1/docsMở Swagger UI cho tài liệu OpenAPI của dự án.NoDone
MODULE 03

User Profile & Social Graph

Completed

Module user gom các API hồ sơ công khai, mention username, chỉ số karma/badge/status profile, follower/following và friend request. QA cần phân biệt route public, route optional token và route bắt buộc Bearer để kiểm thử dữ liệu theo ngữ cảnh người xem.

Public Profile Lookup
Cho phép lấy profile bằng username và tìm username để mention trong nội dung.
  • ✓ GET /api/v1/users/:username with existing username → 200 + user profile
  • ✓ GET /api/v1/users/:username with unknown username → 404 User not found
  • ✓ GET /api/v1/users/mention?q=a → 200 + username suggestion list
  • ✓ GET /api/v1/users/mention without q → 400 Validation failed
Follower Graph
Theo dõi quan hệ follower/following và thao tác follow/unfollow giữa người dùng.
  • ✓ GET /api/v1/user/:username/followers → 200 + paginated followers
  • ✓ GET /api/v1/user/:username/following → 200 + paginated following
  • ✓ POST /api/v1/user/:username/follower with Bearer → 200 + follow state result
  • ✓ POST /api/v1/user/:username/follower without Bearer → 401 TOKEN_INVALID
Friend Requests
Hỗ trợ gửi, hủy, chấp nhận hoặc từ chối lời mời kết bạn và xem danh sách request.
  • ✓ POST /api/v1/me/:username/friend-requests with Bearer → 200 Send request
  • ✓ PATCH /api/v1/me/friend-requests/:username/accept with isAccept true → 200 processed
  • ✓ PATCH /api/v1/me/friend-requests/:username/cancel → 200 processed
  • ✓ GET /api/v1/me/friend-requests/received → 200 + paginated rows
User Progress
Các API cá nhân trả về karma, badges và status profile cho trải nghiệm gamification.
  • ✓ GET /api/v1/users/me/karma with Bearer → 200 + karma payload
  • ✓ GET /api/v1/users/me/badges with Bearer → 200 + badges payload
  • ✓ GET /api/v1/users/me/status-profile with Bearer → 200 + status profile
  • ✓ Any /users/me route with banned account → 403 USER_BANNED

API Endpoints

MethodEndpointDescriptionAuthStatus
GET/api/v1/users/mentionTìm username gợi ý theo query `q` để mention.NoDone
GET/api/v1/users/:usernameLấy hồ sơ người dùng theo username, có thể đọc ngữ cảnh viewer nếu có token.Optional BearerDone
GET/api/v1/users/me/karmaLấy karma của người dùng hiện tại.BearerDone
GET/api/v1/users/me/badgesLấy danh sách badge của người dùng hiện tại.BearerDone
GET/api/v1/users/me/status-profileLấy trạng thái hồ sơ cá nhân của người dùng hiện tại.BearerDone
GET/api/v1/user/:username/followersLấy danh sách follower của username.NoDone
GET/api/v1/user/:username/followingLấy danh sách tài khoản mà username đang follow.NoDone
POST/api/v1/user/:username/friend-requestGửi lời mời kết bạn đến username từ route social công khai.BearerDone
POST/api/v1/user/:username/followerFollow hoặc toggle quan hệ follower với username.BearerDone
GET/api/v1/me/followersLấy follower của chính người dùng đang đăng nhập.BearerDone
POST/api/v1/me/:username/friend-requestsGửi lời mời kết bạn đến username từ route cá nhân.BearerDone
PATCH/api/v1/me/friend-requests/:username/cancelHủy lời mời kết bạn đã gửi cho username.BearerDone
PATCH/api/v1/me/friend-requests/:username/acceptChấp nhận hoặc từ chối lời mời kết bạn từ username theo `isAccept`.BearerDone
GET/api/v1/me/friend-requests/receivedLấy danh sách lời mời kết bạn đã nhận.BearerDone
GET/api/v1/me/friend-requests/sentLấy danh sách lời mời kết bạn đã gửi.BearerDone
MODULE 04

Upload & Media

Completed

Module upload nhận file bằng multer memory storage, resize ảnh qua middleware shape và lưu lên Cloudflare R2/S3-compatible storage. QA cần kiểm tra field name đúng (`file` cho avatar, `medias` cho post media), giới hạn số lượng media và quyền truy cập với route media.

Avatar Upload
Upload một ảnh avatar, xử lý resize và trả về metadata file đã lưu.
  • ✓ POST /api/v1/upload/avatar with multipart field file → 201 Upload avatar success
  • ✓ Missing file in multipart request → middleware/controller error path is returned
  • ✓ Non-image mime type should be rejected by upload/shape middleware
Post Media Upload
Upload tối đa 5 media cho bài viết và trả về danh sách object để gắn vào post payload.
  • ✓ POST /api/v1/upload/media with Bearer + medias[] → 201 Upload media success
  • ✓ More than 5 files in medias[] → upload middleware rejects request
  • ✓ Missing Bearer token on media upload → 401 TOKEN_INVALID

API Endpoints

MethodEndpointDescriptionAuthStatus
POST/api/v1/upload/avatarUpload một file avatar bằng multipart field `file`.NoDone
POST/api/v1/upload/mediaUpload tối đa 5 media bằng multipart field `medias`.BearerDone
MODULE 05

Posts, Feed & Interactions

Completed

Module post xử lý news feed, đọc post công khai, tạo bài viết, reply, quote, repost, like, save, hide, report, sửa và xóa post. QA cần kiểm tra cursor pagination, quyền chủ sở hữu khi sửa/xóa, validate content tối đa 5000 ký tự, poll trong post và các side effect bất đồng bộ như sync like hoặc indexing semantic search.

Feed & Read APIs
Các route đọc post hỗ trợ khách hoặc optional token để cá nhân hóa trạng thái like/save.
  • ✓ GET /api/v1/posts/news-feed?take=20 → 200 + pagination
  • ✓ GET /api/v1/posts/:publicId with existing post → 200 Posts retrieved
  • ✓ GET /api/v1/posts/:publicId with unknown post → 404 Post not found
  • ✓ GET /api/v1/posts/user/:username with unknown username → 404 User not found
Create, Reply, Quote & Repost
Người dùng đăng nhập có thể tạo post thường, reply, quote và repost; nội dung được validate bằng Zod.
  • ✓ POST /api/v1/posts with valid content → 201 Post created
  • ✓ POST /api/v1/posts with empty content → 400 Validation failed
  • ✓ POST /api/v1/posts/:publicId/reply → 201 Post created
  • ✓ POST /api/v1/posts/:publicId/quote → 201 Post created
Engagement Actions
Các hành động like, save, hide, report trả về trạng thái rõ ràng để frontend cập nhật UI.
  • ✓ POST /api/v1/posts/:publicId/like with isLiked true → 200 + liked true
  • ✓ POST /api/v1/posts/:publicId/save → 200 + saved true
  • ✓ POST /api/v1/posts/:publicId/hide → 200 + hidden true
  • ✓ POST /api/v1/posts/:publicId/report without reason → 400 Validation failed
Edit, Delete & Search
Post có thể sửa content/visibility, xóa mềm và tìm kiếm bằng query hoặc semantic similarity.
  • ✓ PATCH /api/v1/posts/:publicId with content or visibility → 200 + updated post
  • ✓ PATCH /api/v1/posts/:publicId with empty body → 400 Validation failed
  • ✓ DELETE /api/v1/posts/:publicId by owner → 200 + deleted true
  • ✓ POST /api/v1/posts/:publicId/similar with content/topic → 200 + similar posts

API Endpoints

MethodEndpointDescriptionAuthStatus
GET/api/v1/posts/news-feedLấy news feed với cursor pagination và filter type tùy chọn.Optional BearerDone
GET/api/v1/posts/searchTìm post bằng query `q`, topics, limit và page.NoDone
GET/api/v1/posts/:publicId/repliesLấy reply của một post theo publicId.Optional BearerDone
GET/api/v1/posts/meLấy post của người dùng đang đăng nhập.BearerDone
GET/api/v1/posts/:publicIdLấy chi tiết post theo publicId.Optional BearerDone
GET/api/v1/posts/user/:usernameLấy post của một username.Optional BearerDone
GET/api/v1/posts/user/:username/repliesLấy reply của một username.Optional BearerDone
GET/api/v1/posts/user/:username/quotesLấy quote post của một username.Optional BearerDone
POST/api/v1/posts/:publicId/similarTìm post tương tự dựa trên content và topic truyền vào body.NoDone
GET/api/v1/posts/:postId/judge-statusLấy trạng thái đánh giá/judge của post theo id số.BearerDone
GET/api/v1/posts/me/repliesLấy reply của người dùng hiện tại.BearerDone
GET/api/v1/posts/me/quoteLấy quote post của người dùng hiện tại.BearerDone
POST/api/v1/postsTạo post mới với content, topic, mentions, media, poll và visibility.BearerDone
POST/api/v1/posts/:publicId/replyTạo reply cho post theo publicId.BearerDone
POST/api/v1/posts/:publicId/likeSet trạng thái like/unlike cho post.BearerDone
POST/api/v1/posts/:publicId/repostRepost một post hiện có.BearerDone
POST/api/v1/posts/:publicId/quoteTạo quote post kèm content mới.BearerDone
POST/api/v1/posts/:publicId/saveLưu post vào danh sách cá nhân.BearerDone
POST/api/v1/posts/:publicId/hideẨn post khỏi trải nghiệm của người dùng hiện tại.BearerDone
POST/api/v1/posts/:publicId/reportBáo cáo post/user/circle với reason và type.BearerDone
PATCH/api/v1/posts/:publicIdCập nhật content hoặc visibility của post.BearerDone
DELETE/api/v1/posts/:publicIdXóa post theo publicId.BearerDone
MODULE 07

Circles & Communities

Completed

Module circle quản lý cộng đồng riêng gồm tạo circle, lời mời, join request, thành viên, phân quyền, bài viết trong circle, reply, điểm năng lượng, CPR, sacrifice karma, thống kê và hỗ trợ AI định dạng nội dung. Tất cả route circle yêu cầu Bearer; QA cần kiểm tra quyền owner/admin/member và trạng thái invitation/join request theo từng vai trò.

Circle Discovery & Creation
Người dùng đăng nhập xem danh sách circle, circle đã tham gia, circle sở hữu và tạo circle mới.
  • ✓ GET /api/v1/circle with Bearer → 200 + paginated circle list
  • ✓ POST /api/v1/circle with description shorter than 40 chars → 400 Validation failed
  • ✓ GET /api/v1/circle/:publicId with valid membership context → 200 circle detail
  • ✓ Any /api/v1/circle route without Bearer → 401 Unauthorized
Invitations & Join Requests
Circle hỗ trợ mời user, phản hồi lời mời, gửi join request, duyệt/từ chối request và gửi lại invitation.
  • ✓ POST /api/v1/circle/send-invitation with circleId/userId → 200 invitation sent
  • ✓ POST /api/v1/circle/response-invitation with ACCEPTED → 200 invitation accepted message
  • ✓ POST /api/v1/circle/:publicId/join-request → 200 sent or cancelled state
  • ✓ POST /api/v1/circle/:publicId/manage/join-request/respond with isAccept → 200 response result
Circle Management
Owner/admin quản lý member, role, ban/kick, invitation stats và log chất lượng post.
  • ✓ GET /api/v1/circle/:publicId/manage/members → 200 + paginated members
  • ✓ PATCH /api/v1/circle/:publicId/manage/members/role with role → 200 updated role
  • ✓ POST /api/v1/circle/:publicId/manage/members/ban with expiresAt datetime → 200 banned result
  • ✓ POST /api/v1/circle/:publicId/manage/members/kick without userId → 400 Validation failed
Circle Posts & Runtime Stats
Circle có bài viết riêng, reply, judge status thông qua log, energy, CPR, sacrifice karma và thống kê theo thời gian.
  • ✓ POST /api/v1/circle/:publicId/posts with content → 202 Post accepted for judging
  • ✓ GET /api/v1/circle/:publicId/posts?sort=quality → 200 + paginated circle posts
  • ✓ POST /api/v1/circle/:publicId/cpr with targetComments → 201 CPR session created
  • ✓ POST /api/v1/circle/:publicId/sacrifice with karmaAmount → 200 Karma sacrificed successfully

API Endpoints

MethodEndpointDescriptionAuthStatus
GET/api/v1/circleLấy danh sách circle theo cursor và visibility tùy chọn.BearerDone
GET/api/v1/circle/me-joinLấy các circle mà người dùng hiện tại đã tham gia.BearerDone
GET/api/v1/circle/me/owner-circleLấy các circle do người dùng hiện tại sở hữu.BearerDone
GET/api/v1/circle/request-invitationLấy danh sách invitation/join request liên quan đến người dùng hiện tại.BearerDone
GET/api/v1/circle/invitations/me/:publicIdLấy chi tiết invitation của người dùng hiện tại trong một circle.BearerDone
POST/api/v1/circleTạo circle mới với name, description, avatarEmoji, visibility và mediaUrls.BearerDone
POST/api/v1/circle/send-invitationGửi invitation đến userId cho circleId.BearerDone
POST/api/v1/circle/response-invitationChấp nhận hoặc từ chối invitation bằng status ACCEPTED/REJECTED.BearerDone
POST/api/v1/circle/:publicId/level-upNâng cấp level circle nếu đủ điều kiện.BearerDone
GET/api/v1/circle/:publicId/energyLấy trạng thái energy của circle.BearerDone
GET/api/v1/circle/:publicId/user-quantity-postLấy số lượng post của user hiện tại trong circle.BearerDone
GET/api/v1/circle/:publicId/manage/exp-logLấy log điểm kinh nghiệm của circle.BearerDone
GET/api/v1/circle/:publicId/manage/post-quality-logLấy log chất lượng post của circle.BearerDone
GET/api/v1/circle/:publicId/manage/membersLấy danh sách member cho màn quản trị circle.BearerDone
PATCH/api/v1/circle/:publicId/manage/members/roleCập nhật role của member trong circle.BearerDone
POST/api/v1/circle/:publicId/manage/members/banBan member khỏi circle với reason và expiresAt tùy chọn.BearerDone
POST/api/v1/circle/:publicId/manage/members/kickKick member khỏi circle.BearerDone
GET/api/v1/circle/:publicId/manage/invitations/statsLấy thống kê invitation của circle.BearerDone
GET/api/v1/circle/:publicId/manage/invitationsLấy danh sách invitation trong màn quản trị circle.BearerDone
GET/api/v1/circle/:publicId/manage/join-requestsLấy danh sách join request đang chờ duyệt.BearerDone
POST/api/v1/circle/:publicId/manage/resendGửi lại invitation theo id invitation.BearerDone
POST/api/v1/circle/:publicId/manage/join-request/respondAdmin/manager duyệt hoặc từ chối join request.BearerDone
POST/api/v1/circle/:publicId/send-invitation/manageAdmin gửi invitation theo username, role và description.BearerDone
POST/api/v1/circle/:publicId/postsTạo post trong circle và đưa vào luồng judging.BearerDone
GET/api/v1/circle/:publicId/postsLấy danh sách post trong circle theo sort latest hoặc quality.BearerDone
POST/api/v1/circle/:publicId/join-requestGửi hoặc hủy join request của user hiện tại.BearerDone
POST/api/v1/circle/:publicId/join-request/respond-invitationUser phản hồi invitation/join request bằng isAccept.BearerDone
POST/api/v1/circle/:publicId/posts/:postPublicId/replyTạo reply cho post trong circle và đưa vào luồng judging.BearerDone
GET/api/v1/circle/:publicId/posts/:postPublicId/repliesLấy reply của một post trong circle.BearerDone
POST/api/v1/circle/:publicId/cprTạo CPR session với targetComments.BearerDone
GET/api/v1/circle/:publicId/cpr/statusLấy trạng thái CPR của circle.BearerDone
POST/api/v1/circle/:publicId/sacrificeHy sinh karma cá nhân để hỗ trợ circle.BearerDone
GET/api/v1/circle/:publicId/statsLấy thống kê circle theo khoảng 7days, 30days hoặc 90days.BearerDone
GET/api/v1/circle/:publicId/membersLấy member của circle theo cursor pagination.BearerDone
GET/api/v1/circle/:publicIdLấy chi tiết circle theo publicId.BearerDone
POST/api/v1/circle-ai/generate-responseĐịnh dạng hoặc hiệu đính content thành Markdown bằng AI cho circle content.BearerDone
MODULE 08

Polls & Quests

Completed

Module poll ghi nhận vote cho survey/poll gắn với post, còn quest quản lý daily quest và claim thưởng karma. QA cần kiểm tra mỗi vote có pollId và pollOptionId hợp lệ, quest code đúng định dạng và không claim trùng khi business rule không cho phép.

Poll Voting
Người dùng đăng nhập chọn một option trong poll, service trả về trạng thái vote đã ghi nhận.
  • ✓ POST /api/v1/polls/:pollId/vote with pollOptionId → 200 Vote created successfully
  • ✓ POST /api/v1/polls/:pollId/vote with non-number pollId → 400 Validation failed
  • ✓ POST /api/v1/polls/:pollId/vote without Bearer → 401 TOKEN_INVALID
Daily Quest Claim
Daily quest hiển thị nhiệm vụ khả dụng và cho phép claim reward theo code.
  • ✓ GET /api/v1/quests/daily with Bearer → 200 Daily quests retrieved successfully
  • ✓ POST /api/v1/quests/:code/claim with valid code → 200 Quest claimed successfully
  • ✓ POST /api/v1/quests/:code/claim with empty code path → route not matched or validation error

API Endpoints

MethodEndpointDescriptionAuthStatus
POST/api/v1/polls/:pollId/voteTạo hoặc cập nhật vote của user cho một poll option.BearerDone
GET/api/v1/quests/dailyLấy danh sách daily quest của user hiện tại.BearerDone
POST/api/v1/quests/:code/claimClaim reward cho daily quest theo code.BearerDone
MODULE 09

Messaging & Realtime

Completed

Module messaging quản lý nhóm chat, gửi tin nhắn, trạng thái delivery, danh sách member, notification unread và cấp quyền Pusher private channel. QA cần kiểm tra membership của message group trước khi đọc/gửi tin và xác thực channel name đúng với user hoặc group.

Message Groups
Tạo private/crowd group, liệt kê group của user và đọc member trong group.
  • ✓ POST /api/v1/message-groups with type private and members[] → 201 created
  • ✓ POST /api/v1/message-groups with invalid type → 400 Validation failed
  • ✓ GET /api/v1/message-groups → 200 + paginated groups
  • ✓ GET /api/v1/message-groups/:publicId/members as non-member → 403 or Unauthorized path
Messages & Delivery
Tin nhắn yêu cầu content và clientMessageId để chống gửi trùng từ client.
  • ✓ POST /api/v1/message-groups/:publicId/messages with content/clientMessageId → 201 Message sent
  • ✓ POST message with content over 1000 chars → 400 Validation failed
  • ✓ PATCH /api/v1/message-groups/:publicId/messages/:messagePublicId/status with isDelivery true → 200 updated
  • ✓ GET /api/v1/message-groups/:publicId/messages → 200 + paginated messages
Notifications
Notification APIs trả về list notification, trạng thái unread, số group chat chưa đọc và số friend request.
  • ✓ GET /api/v1/notification → 200 + paginated notifications
  • ✓ GET /api/v1/notification/unread → 200 + isNotification boolean
  • ✓ POST /api/v1/notification/read → 200 + isRead true
  • ✓ GET /api/v1/notification/message → 200 + unreadGroupCount
Pusher Private Auth
Pusher auth kiểm tra private channel, socket id và membership trước khi trả signature.
  • ✓ POST /api/v1/pusher/auth with private notification channel for same user → Pusher auth payload
  • ✓ POST /api/v1/pusher/auth with public channel name → 400 Only private channels are supported
  • ✓ POST /api/v1/pusher/auth for inaccessible chat channel → 403 Channel is not accessible

API Endpoints

MethodEndpointDescriptionAuthStatus
GET/api/v1/notificationLấy danh sách notification của user hiện tại.BearerDone
GET/api/v1/notification/unreadKiểm tra user có notification chưa đọc hay không.BearerDone
POST/api/v1/notification/readĐánh dấu notification group là đã đọc.BearerDone
GET/api/v1/notification/messageLấy số lượng message group chưa đọc.BearerDone
GET/api/v1/notification/friend-requestLấy số lượng friend request đã nhận.BearerDone
POST/api/v1/message-groupsTạo message group private hoặc crowd.BearerDone
GET/api/v1/message-groupsLấy danh sách message group của user.BearerDone
POST/api/v1/message-groups/:publicId/messagesGửi message vào group theo publicId.BearerDone
PATCH/api/v1/message-groups/:publicId/messages/:messagePublicId/statusCập nhật trạng thái delivery của message.BearerDone
GET/api/v1/message-groups/:publicId/messagesLấy tin nhắn trong group theo cursor.BearerDone
GET/api/v1/message-groups/:publicId/membersLấy danh sách member của group.BearerDone
POST/api/v1/pusher/authCấp quyền subscribe Pusher private channel nếu user hợp lệ.BearerDone
MODULE 10

Museum Archive

Completed

Module museum cung cấp danh sách và chi tiết item lưu trữ theo publicId. Cả hai endpoint đều yêu cầu Bearer token; QA cần kiểm tra query filter, pagination nếu có trong DTO và hành vi khi publicId không tồn tại.

Archive Listing
Người dùng đăng nhập xem danh sách museum theo query đã validate.
  • ✓ GET /api/v1/museum with Bearer → 200 Museum list retrieved successfully
  • ✓ GET /api/v1/museum without Bearer → 401 TOKEN_INVALID
  • ✓ Invalid query values → 400 Validation failed
Archive Detail
Chi tiết museum trả dữ liệu theo publicId đã validate trong params.
  • ✓ GET /api/v1/museum/:publicId with valid id → 200 Museum detail retrieved successfully
  • ✓ GET /api/v1/museum/:publicId with empty segment → route not matched
  • ✓ Unknown publicId should return the service error defined by repository lookup

API Endpoints

MethodEndpointDescriptionAuthStatus
GET/api/v1/museumLấy danh sách item museum theo query.BearerDone
GET/api/v1/museum/:publicIdLấy chi tiết một item museum theo publicId.BearerDone
MODULE 11

AI & Webhooks

Completed

Module integration gồm tạo job image AI qua Leonardo/OpenRouter flow và nhận webhook từ HLS/Leonardo để cập nhật trạng thái media hoặc generation metadata. QA cần kiểm tra bảo mật webhook bằng header, xử lý event không hỗ trợ và payload trả về khi job được tạo.

Image Generation Job
Người dùng đăng nhập gửi content để tạo image generation job; response không trả các field cost nhạy cảm.
  • ✓ POST /api/v1/ai/generate-image with content → 200 Image generation job created
  • ✓ Response data.sdGenerationJob does not expose apiCreditCost or cost
  • ✓ Missing Bearer token → 401 TOKEN_INVALID
  • ✓ Missing content → 400 Validation failed
HLS Media Webhook
Webhook HLS xác thực bằng `x-webhook-signature` và cập nhật status media theo event ready, errored hoặc deleted.
  • ✓ POST /api/v1/webhooks/hls with valid signature and video.asset.ready → 200 Webhook received
  • ✓ Missing x-webhook-signature → 400 Missing signature
  • ✓ Invalid x-webhook-signature → 401 Invalid signature
  • ✓ Unsupported event type → 200 with empty response body
Leonardo Webhook
Webhook Leonardo xác thực bằng Bearer hoặc `x-leonardo-webhook-api-key`, cập nhật generation metadata và phát Pusher event.
  • ✓ POST /api/v1/webhooks/leonardo with valid key → 200 Leonardo webhook received
  • ✓ Invalid Leonardo key → 401 Invalid webhook key
  • ✓ Payload object other than generation → 200 + received true

API Endpoints

MethodEndpointDescriptionAuthStatus
POST/api/v1/ai/generate-imageTạo job sinh ảnh từ content của user hiện tại.BearerDone
POST/api/v1/webhooks/hlsNhận webhook HLS để cập nhật trạng thái media video.x-webhook-signatureDone
POST/api/v1/webhooks/leonardoNhận webhook Leonardo để cập nhật metadata generation và trigger realtime event.Webhook keyDone
MODULE 12

Admin Operations

Completed

Module admin cung cấp đăng nhập admin, quản lý user ban/unban, report moderation, trending hashtag, dashboard statistics và daily quest. Ngoại trừ `/admin/login`, các route admin đều đi qua authorization và `checkRole(UserRoleType.ADMIN)`, nên QA cần kiểm tra cả token hợp lệ và role admin.

Admin Login & User Controls
Admin đăng nhập bằng credential hợp lệ và quản lý trạng thái ban của user.
  • ✓ POST /api/v1/admin/login with admin credentials → 200 + token pair
  • ✓ GET /api/v1/admin/users with admin Bearer → 200 + paginated users
  • ✓ PATCH /api/v1/admin/users/:userId/ban with durationHours → 200 banned result
  • ✓ Non-admin Bearer on /api/v1/admin/users → 403 Forbidden
Report Moderation
Admin xem danh sách report, xem chi tiết và xử lý report bằng action hợp lệ.
  • ✓ GET /api/v1/admin/reports?type=post → 200 + paginated reports
  • ✓ GET /api/v1/admin/reports/:reportId → 200 Report details retrieved successfully
  • ✓ PATCH /api/v1/admin/reports/:reportId with action → 200 Report moderated successfully
  • ✓ PATCH report with invalid action → 400 Validation failed
Dashboard & Trends
Admin lấy số liệu tổng quan và hashtag trending phục vụ CMS/dashboard.
  • ✓ GET /api/v1/admin/stats with admin Bearer → 200 Admin statistics retrieved successfully
  • ✓ GET /api/v1/admin/hashtags/trending → 200 + paginated hashtags
  • ✓ Invalid page or limit query → 400 Validation failed
Daily Quest Administration
Admin tạo, liệt kê, xem action options và disable daily quest theo code.
  • ✓ POST /api/v1/admin/daily-quests with valid payload → 201 Daily quest created successfully
  • ✓ GET /api/v1/admin/daily-quests/actions → 200 Daily quest actions retrieved successfully
  • ✓ GET /api/v1/admin/daily-quests → 200 + paginated daily quests
  • ✓ PATCH /api/v1/admin/daily-quests/:code/disable → 200 Daily quest disabled successfully

API Endpoints

MethodEndpointDescriptionAuthStatus
POST/api/v1/admin/loginĐăng nhập admin và trả về token khi credential hợp lệ.NoDone
GET/api/v1/admin/usersLấy danh sách user cho CMS admin.Bearer + Admin roleDone
PATCH/api/v1/admin/users/:userId/banBan user trong khoảng thời gian `durationHours`.Bearer + Admin roleDone
PATCH/api/v1/admin/users/:userId/unbanGỡ ban user.Bearer + Admin roleDone
PATCH/api/v1/admin/users/:userId/ban-unlimitedBan user vô thời hạn.Bearer + Admin roleDone
GET/api/v1/admin/reportsLấy danh sách report theo type/status và pagination.Bearer + Admin roleDone
GET/api/v1/admin/reports/:reportIdLấy chi tiết một report.Bearer + Admin roleDone
PATCH/api/v1/admin/reports/:reportIdModerate report bằng action và adminNote tùy chọn.Bearer + Admin roleDone
GET/api/v1/admin/hashtags/trendingLấy danh sách hashtag trending cho admin.Bearer + Admin roleDone
GET/api/v1/admin/statsLấy số liệu dashboard tổng quan.Bearer + Admin roleDone
POST/api/v1/admin/daily-questsTạo daily quest mới.Bearer + Admin roleDone
GET/api/v1/admin/daily-quests/actionsLấy danh sách action type hợp lệ cho daily quest.Bearer + Admin roleDone
GET/api/v1/admin/daily-questsLấy danh sách daily quest trong CMS admin.Bearer + Admin roleDone
PATCH/api/v1/admin/daily-quests/:code/disableDisable daily quest theo code.Bearer + Admin roleDone