Tóm tắt endpoint
| Method | Path | Mô tả | Auth | Rate limit |
|---|
| GET | /api/v1/me/followers | Followers của user hiện tại. | Bearer | Global apiLimiter; một số flow có Redis/domain limit riêng. |
| POST | /api/v1/me/:username/friend-requests | Gửi friend request. | Bearer | Global apiLimiter; một số flow có Redis/domain limit riêng. |
| PATCH | /api/v1/me/friend-requests/:username/cancel | Hủy request. | Bearer | Global apiLimiter; một số flow có Redis/domain limit riêng. |
| PATCH | /api/v1/me/friend-requests/:username/accept | Accept/reject request. | Bearer | Global apiLimiter; một số flow có Redis/domain limit riêng. |
| GET | /api/v1/me/friend-requests/received | Request nhận được. | Bearer | Global apiLimiter; một số flow có Redis/domain limit riêng. |
| GET | /api/v1/me/friend-requests/sent | Request đã gửi. | Bearer | Global apiLimiter; một số flow có Redis/domain limit riêng. |
| GET | /api/v1/users/mention | Search username để mention. | Bearer | Global apiLimiter; một số flow có Redis/domain limit riêng. |
| GET | /api/v1/users/:username | Profile by username. | Bearer | Global apiLimiter; một số flow có Redis/domain limit riêng. |
| GET | /api/v1/users/me/karma | Karma. [CẦN XÁC NHẬN] response mock. | Bearer | Global apiLimiter; một số flow có Redis/domain limit riêng. |
| GET | /api/v1/users/me/badges | Badges. [CẦN XÁC NHẬN] response mock. | Bearer | Global apiLimiter; một số flow có Redis/domain limit riêng. |
| GET | /api/v1/user/:username/followers | Followers public. | Public | Global apiLimiter; một số flow có Redis/domain limit riêng. |
| GET | /api/v1/user/:username/following | Following public. | Public | Global apiLimiter; một số flow có Redis/domain limit riêng. |
| POST | /api/v1/user/:username/follower | Toggle follow. | Bearer | Global apiLimiter; một số flow có Redis/domain limit riêng. |
GET /api/v1/me/followers
GET Auth required apiLimiter
Endpoint này dùng để followers của user hiện tại. Gọi endpoint này khi client cần thao tác đúng phạm vi module user.
Request
| Header | Giá trị | Bắt buộc | Mô tả |
|---|
| Authorization | Bearer accessToken | Có | JWT access token nếu route protected |
| x-refresh-token | raw refresh token | Không | Refresh token header theo middleware |
| Parameter | Kiểu | Mô tả | Ví dụ |
|---|
| path params | string | Các phần :publicId, :username, :code nếu path có | cm123 |
| query params | string/number | take, after, page, limit hoặc module-specific query | take=20 |
| Field | Kiểu | Bắt buộc | Validation | Mô tả | Ví dụ giá trị |
|---|
| body | object | Không | Theo DTO Zod nếu route có validate() | Payload nghiệp vụ của endpoint | {"content":"Hello"} |
Ví dụ request
curl -X GET http://localhost:3302/api/v1/me/followers \
-H "Authorization: Bearer ACCESS_TOKEN" \
-H "Content-Type: application/json"
Response
200/201 — Thành công
| Field | Kiểu | Luôn có? | Mô tả |
|---|
| success | boolean | Có | true khi request thành công |
| message | string | Không | Một số controller truyền message |
| data | object/array | Tùy endpoint | Dữ liệu trả về từ service |
| pagination | object | Với list | Cursor/offset pagination |
{
"success": true,
"data": {
"module": "user",
"endpoint": "/api/v1/me/followers"
}
}
Lỗi có thể xảy ra
| HTTP Status | Error Code | Khi nào xảy ra | Cách xử lý ở client |
|---|
| 401 | UNAUTHORIZED | Unauthorized | Login lại hoặc refresh token. |
| 400 | VALIDATION_FAILED | Validation failed | Client sửa field sai. |
| 404 | NOT_FOUND | Resource not found | Refresh dữ liệu. |
| 403 | FORBIDDEN | Forbidden | Ẩn action trong UI. |
| 500 | INTERNAL_SERVER_ERROR | External dependency fail | On-call kiểm tra provider/log. |
Ví dụ lỗi
{
"success": false,
"message": "Validation failed"
}
Ghi chú
- Endpoint đi qua global
apiLimiter. - Idempotency không được đảm bảo trừ khi service có upsert/unique constraint riêng.
- Follow chính mình trả isFollowing:false.
POST /api/v1/me/:username/friend-requests
POST Auth required apiLimiter
Endpoint này dùng để gửi friend request. Gọi endpoint này khi client cần thao tác đúng phạm vi module user.
Request
| Header | Giá trị | Bắt buộc | Mô tả |
|---|
| Authorization | Bearer accessToken | Có | JWT access token nếu route protected |
| x-refresh-token | raw refresh token | Không | Refresh token header theo middleware |
| Parameter | Kiểu | Mô tả | Ví dụ |
|---|
| path params | string | Các phần :publicId, :username, :code nếu path có | cm123 |
| query params | string/number | take, after, page, limit hoặc module-specific query | take=20 |
| Field | Kiểu | Bắt buộc | Validation | Mô tả | Ví dụ giá trị |
|---|
| body | object | Tùy endpoint | Theo DTO Zod nếu route có validate() | Payload nghiệp vụ của endpoint | {"content":"Hello"} |
Ví dụ request
curl -X POST http://localhost:3302/api/v1/me/alice/friend-requests \
-H "Authorization: Bearer ACCESS_TOKEN" \
-H "Content-Type: application/json"
Response
200/201 — Thành công
| Field | Kiểu | Luôn có? | Mô tả |
|---|
| success | boolean | Có | true khi request thành công |
| message | string | Không | Một số controller truyền message |
| data | object/array | Tùy endpoint | Dữ liệu trả về từ service |
| pagination | object | Với list | Cursor/offset pagination |
{
"success": true,
"data": {
"module": "user",
"endpoint": "/api/v1/me/:username/friend-requests"
}
}
Lỗi có thể xảy ra
| HTTP Status | Error Code | Khi nào xảy ra | Cách xử lý ở client |
|---|
| 401 | UNAUTHORIZED | Unauthorized | Login lại hoặc refresh token. |
| 400 | VALIDATION_FAILED | Validation failed | Client sửa field sai. |
| 404 | NOT_FOUND | Resource not found | Refresh dữ liệu. |
| 403 | FORBIDDEN | Forbidden | Ẩn action trong UI. |
| 500 | INTERNAL_SERVER_ERROR | External dependency fail | On-call kiểm tra provider/log. |
Ví dụ lỗi
{
"success": false,
"message": "Validation failed"
}
Ghi chú
- Endpoint đi qua global
apiLimiter. - Idempotency không được đảm bảo trừ khi service có upsert/unique constraint riêng.
- Follow chính mình trả isFollowing:false.
PATCH /api/v1/me/friend-requests/:username/cancel
PATCH Auth required apiLimiter
Endpoint này dùng để hủy request. Gọi endpoint này khi client cần thao tác đúng phạm vi module user.
Request
| Header | Giá trị | Bắt buộc | Mô tả |
|---|
| Authorization | Bearer accessToken | Có | JWT access token nếu route protected |
| x-refresh-token | raw refresh token | Không | Refresh token header theo middleware |
| Parameter | Kiểu | Mô tả | Ví dụ |
|---|
| path params | string | Các phần :publicId, :username, :code nếu path có | cm123 |
| query params | string/number | take, after, page, limit hoặc module-specific query | take=20 |
| Field | Kiểu | Bắt buộc | Validation | Mô tả | Ví dụ giá trị |
|---|
| body | object | Tùy endpoint | Theo DTO Zod nếu route có validate() | Payload nghiệp vụ của endpoint | {"content":"Hello"} |
Ví dụ request
curl -X PATCH http://localhost:3302/api/v1/me/friend-requests/alice/cancel \
-H "Authorization: Bearer ACCESS_TOKEN" \
-H "Content-Type: application/json"
Response
200/201 — Thành công
| Field | Kiểu | Luôn có? | Mô tả |
|---|
| success | boolean | Có | true khi request thành công |
| message | string | Không | Một số controller truyền message |
| data | object/array | Tùy endpoint | Dữ liệu trả về từ service |
| pagination | object | Với list | Cursor/offset pagination |
{
"success": true,
"data": {
"module": "user",
"endpoint": "/api/v1/me/friend-requests/:username/cancel"
}
}
Lỗi có thể xảy ra
| HTTP Status | Error Code | Khi nào xảy ra | Cách xử lý ở client |
|---|
| 401 | UNAUTHORIZED | Unauthorized | Login lại hoặc refresh token. |
| 400 | VALIDATION_FAILED | Validation failed | Client sửa field sai. |
| 404 | NOT_FOUND | Resource not found | Refresh dữ liệu. |
| 403 | FORBIDDEN | Forbidden | Ẩn action trong UI. |
| 500 | INTERNAL_SERVER_ERROR | External dependency fail | On-call kiểm tra provider/log. |
Ví dụ lỗi
{
"success": false,
"message": "Validation failed"
}
Ghi chú
- Endpoint đi qua global
apiLimiter. - Idempotency không được đảm bảo trừ khi service có upsert/unique constraint riêng.
- Follow chính mình trả isFollowing:false.
PATCH /api/v1/me/friend-requests/:username/accept
PATCH Auth required apiLimiter
Endpoint này dùng để accept/reject request. Gọi endpoint này khi client cần thao tác đúng phạm vi module user.
Request
| Header | Giá trị | Bắt buộc | Mô tả |
|---|
| Authorization | Bearer accessToken | Có | JWT access token nếu route protected |
| x-refresh-token | raw refresh token | Không | Refresh token header theo middleware |
| Parameter | Kiểu | Mô tả | Ví dụ |
|---|
| path params | string | Các phần :publicId, :username, :code nếu path có | cm123 |
| query params | string/number | take, after, page, limit hoặc module-specific query | take=20 |
| Field | Kiểu | Bắt buộc | Validation | Mô tả | Ví dụ giá trị |
|---|
| body | object | Tùy endpoint | Theo DTO Zod nếu route có validate() | Payload nghiệp vụ của endpoint | {"content":"Hello"} |
Ví dụ request
curl -X PATCH http://localhost:3302/api/v1/me/friend-requests/alice/accept \
-H "Authorization: Bearer ACCESS_TOKEN" \
-H "Content-Type: application/json"
Response
200/201 — Thành công
| Field | Kiểu | Luôn có? | Mô tả |
|---|
| success | boolean | Có | true khi request thành công |
| message | string | Không | Một số controller truyền message |
| data | object/array | Tùy endpoint | Dữ liệu trả về từ service |
| pagination | object | Với list | Cursor/offset pagination |
{
"success": true,
"data": {
"module": "user",
"endpoint": "/api/v1/me/friend-requests/:username/accept"
}
}
Lỗi có thể xảy ra
| HTTP Status | Error Code | Khi nào xảy ra | Cách xử lý ở client |
|---|
| 401 | UNAUTHORIZED | Unauthorized | Login lại hoặc refresh token. |
| 400 | VALIDATION_FAILED | Validation failed | Client sửa field sai. |
| 404 | NOT_FOUND | Resource not found | Refresh dữ liệu. |
| 403 | FORBIDDEN | Forbidden | Ẩn action trong UI. |
| 500 | INTERNAL_SERVER_ERROR | External dependency fail | On-call kiểm tra provider/log. |
Ví dụ lỗi
{
"success": false,
"message": "Validation failed"
}
Ghi chú
- Endpoint đi qua global
apiLimiter. - Idempotency không được đảm bảo trừ khi service có upsert/unique constraint riêng.
- Follow chính mình trả isFollowing:false.
GET /api/v1/me/friend-requests/received
GET Auth required apiLimiter
Endpoint này dùng để request nhận được. Gọi endpoint này khi client cần thao tác đúng phạm vi module user.
Request
| Header | Giá trị | Bắt buộc | Mô tả |
|---|
| Authorization | Bearer accessToken | Có | JWT access token nếu route protected |
| x-refresh-token | raw refresh token | Không | Refresh token header theo middleware |
| Parameter | Kiểu | Mô tả | Ví dụ |
|---|
| path params | string | Các phần :publicId, :username, :code nếu path có | cm123 |
| query params | string/number | take, after, page, limit hoặc module-specific query | take=20 |
| Field | Kiểu | Bắt buộc | Validation | Mô tả | Ví dụ giá trị |
|---|
| body | object | Không | Theo DTO Zod nếu route có validate() | Payload nghiệp vụ của endpoint | {"content":"Hello"} |
Ví dụ request
curl -X GET http://localhost:3302/api/v1/me/friend-requests/received \
-H "Authorization: Bearer ACCESS_TOKEN" \
-H "Content-Type: application/json"
Response
200/201 — Thành công
| Field | Kiểu | Luôn có? | Mô tả |
|---|
| success | boolean | Có | true khi request thành công |
| message | string | Không | Một số controller truyền message |
| data | object/array | Tùy endpoint | Dữ liệu trả về từ service |
| pagination | object | Với list | Cursor/offset pagination |
{
"success": true,
"data": {
"module": "user",
"endpoint": "/api/v1/me/friend-requests/received"
}
}
Lỗi có thể xảy ra
| HTTP Status | Error Code | Khi nào xảy ra | Cách xử lý ở client |
|---|
| 401 | UNAUTHORIZED | Unauthorized | Login lại hoặc refresh token. |
| 400 | VALIDATION_FAILED | Validation failed | Client sửa field sai. |
| 404 | NOT_FOUND | Resource not found | Refresh dữ liệu. |
| 403 | FORBIDDEN | Forbidden | Ẩn action trong UI. |
| 500 | INTERNAL_SERVER_ERROR | External dependency fail | On-call kiểm tra provider/log. |
Ví dụ lỗi
{
"success": false,
"message": "Validation failed"
}
Ghi chú
- Endpoint đi qua global
apiLimiter. - Idempotency không được đảm bảo trừ khi service có upsert/unique constraint riêng.
- Follow chính mình trả isFollowing:false.
GET /api/v1/me/friend-requests/sent
GET Auth required apiLimiter
Endpoint này dùng để request đã gửi. Gọi endpoint này khi client cần thao tác đúng phạm vi module user.
Request
| Header | Giá trị | Bắt buộc | Mô tả |
|---|
| Authorization | Bearer accessToken | Có | JWT access token nếu route protected |
| x-refresh-token | raw refresh token | Không | Refresh token header theo middleware |
| Parameter | Kiểu | Mô tả | Ví dụ |
|---|
| path params | string | Các phần :publicId, :username, :code nếu path có | cm123 |
| query params | string/number | take, after, page, limit hoặc module-specific query | take=20 |
| Field | Kiểu | Bắt buộc | Validation | Mô tả | Ví dụ giá trị |
|---|
| body | object | Không | Theo DTO Zod nếu route có validate() | Payload nghiệp vụ của endpoint | {"content":"Hello"} |
Ví dụ request
curl -X GET http://localhost:3302/api/v1/me/friend-requests/sent \
-H "Authorization: Bearer ACCESS_TOKEN" \
-H "Content-Type: application/json"
Response
200/201 — Thành công
| Field | Kiểu | Luôn có? | Mô tả |
|---|
| success | boolean | Có | true khi request thành công |
| message | string | Không | Một số controller truyền message |
| data | object/array | Tùy endpoint | Dữ liệu trả về từ service |
| pagination | object | Với list | Cursor/offset pagination |
{
"success": true,
"data": {
"module": "user",
"endpoint": "/api/v1/me/friend-requests/sent"
}
}
Lỗi có thể xảy ra
| HTTP Status | Error Code | Khi nào xảy ra | Cách xử lý ở client |
|---|
| 401 | UNAUTHORIZED | Unauthorized | Login lại hoặc refresh token. |
| 400 | VALIDATION_FAILED | Validation failed | Client sửa field sai. |
| 404 | NOT_FOUND | Resource not found | Refresh dữ liệu. |
| 403 | FORBIDDEN | Forbidden | Ẩn action trong UI. |
| 500 | INTERNAL_SERVER_ERROR | External dependency fail | On-call kiểm tra provider/log. |
Ví dụ lỗi
{
"success": false,
"message": "Validation failed"
}
Ghi chú
- Endpoint đi qua global
apiLimiter. - Idempotency không được đảm bảo trừ khi service có upsert/unique constraint riêng.
- Follow chính mình trả isFollowing:false.
GET /api/v1/users/mention
GET Auth required apiLimiter
Endpoint này dùng để search username để mention. Gọi endpoint này khi client cần thao tác đúng phạm vi module user.
Request
| Header | Giá trị | Bắt buộc | Mô tả |
|---|
| Authorization | Bearer accessToken | Có | JWT access token nếu route protected |
| x-refresh-token | raw refresh token | Không | Refresh token header theo middleware |
| Parameter | Kiểu | Mô tả | Ví dụ |
|---|
| path params | string | Các phần :publicId, :username, :code nếu path có | cm123 |
| query params | string/number | take, after, page, limit hoặc module-specific query | take=20 |
| Field | Kiểu | Bắt buộc | Validation | Mô tả | Ví dụ giá trị |
|---|
| body | object | Không | Theo DTO Zod nếu route có validate() | Payload nghiệp vụ của endpoint | {"content":"Hello"} |
Ví dụ request
curl -X GET http://localhost:3302/api/v1/users/mention \
-H "Authorization: Bearer ACCESS_TOKEN" \
-H "Content-Type: application/json"
Response
200/201 — Thành công
| Field | Kiểu | Luôn có? | Mô tả |
|---|
| success | boolean | Có | true khi request thành công |
| message | string | Không | Một số controller truyền message |
| data | object/array | Tùy endpoint | Dữ liệu trả về từ service |
| pagination | object | Với list | Cursor/offset pagination |
{
"success": true,
"data": {
"module": "user",
"endpoint": "/api/v1/users/mention"
}
}
Lỗi có thể xảy ra
| HTTP Status | Error Code | Khi nào xảy ra | Cách xử lý ở client |
|---|
| 401 | UNAUTHORIZED | Unauthorized | Login lại hoặc refresh token. |
| 400 | VALIDATION_FAILED | Validation failed | Client sửa field sai. |
| 404 | NOT_FOUND | Resource not found | Refresh dữ liệu. |
| 403 | FORBIDDEN | Forbidden | Ẩn action trong UI. |
| 500 | INTERNAL_SERVER_ERROR | External dependency fail | On-call kiểm tra provider/log. |
Ví dụ lỗi
{
"success": false,
"message": "Validation failed"
}
Ghi chú
- Endpoint đi qua global
apiLimiter. - Idempotency không được đảm bảo trừ khi service có upsert/unique constraint riêng.
- Follow chính mình trả isFollowing:false.
GET /api/v1/users/:username
GET Auth required apiLimiter
Endpoint này dùng để profile by username. Gọi endpoint này khi client cần thao tác đúng phạm vi module user.
Request
| Header | Giá trị | Bắt buộc | Mô tả |
|---|
| Authorization | Bearer accessToken | Có | JWT access token nếu route protected |
| x-refresh-token | raw refresh token | Không | Refresh token header theo middleware |
| Parameter | Kiểu | Mô tả | Ví dụ |
|---|
| path params | string | Các phần :publicId, :username, :code nếu path có | cm123 |
| query params | string/number | take, after, page, limit hoặc module-specific query | take=20 |
| Field | Kiểu | Bắt buộc | Validation | Mô tả | Ví dụ giá trị |
|---|
| body | object | Không | Theo DTO Zod nếu route có validate() | Payload nghiệp vụ của endpoint | {"content":"Hello"} |
Ví dụ request
curl -X GET http://localhost:3302/api/v1/users/alice \
-H "Authorization: Bearer ACCESS_TOKEN" \
-H "Content-Type: application/json"
Response
200/201 — Thành công
| Field | Kiểu | Luôn có? | Mô tả |
|---|
| success | boolean | Có | true khi request thành công |
| message | string | Không | Một số controller truyền message |
| data | object/array | Tùy endpoint | Dữ liệu trả về từ service |
| pagination | object | Với list | Cursor/offset pagination |
{
"success": true,
"data": {
"module": "user",
"endpoint": "/api/v1/users/:username"
}
}
Lỗi có thể xảy ra
| HTTP Status | Error Code | Khi nào xảy ra | Cách xử lý ở client |
|---|
| 401 | UNAUTHORIZED | Unauthorized | Login lại hoặc refresh token. |
| 400 | VALIDATION_FAILED | Validation failed | Client sửa field sai. |
| 404 | NOT_FOUND | Resource not found | Refresh dữ liệu. |
| 403 | FORBIDDEN | Forbidden | Ẩn action trong UI. |
| 500 | INTERNAL_SERVER_ERROR | External dependency fail | On-call kiểm tra provider/log. |
Ví dụ lỗi
{
"success": false,
"message": "Validation failed"
}
Ghi chú
- Endpoint đi qua global
apiLimiter. - Idempotency không được đảm bảo trừ khi service có upsert/unique constraint riêng.
- Follow chính mình trả isFollowing:false.
GET /api/v1/users/me/karma
GET Auth required apiLimiter
Endpoint này dùng để karma. [CẦN XÁC NHẬN] response mock. Gọi endpoint này khi client cần thao tác đúng phạm vi module user.
Request
| Header | Giá trị | Bắt buộc | Mô tả |
|---|
| Authorization | Bearer accessToken | Có | JWT access token nếu route protected |
| x-refresh-token | raw refresh token | Không | Refresh token header theo middleware |
| Parameter | Kiểu | Mô tả | Ví dụ |
|---|
| path params | string | Các phần :publicId, :username, :code nếu path có | cm123 |
| query params | string/number | take, after, page, limit hoặc module-specific query | take=20 |
| Field | Kiểu | Bắt buộc | Validation | Mô tả | Ví dụ giá trị |
|---|
| body | object | Không | Theo DTO Zod nếu route có validate() | Payload nghiệp vụ của endpoint | {"content":"Hello"} |
Ví dụ request
curl -X GET http://localhost:3302/api/v1/users/me/karma \
-H "Authorization: Bearer ACCESS_TOKEN" \
-H "Content-Type: application/json"
Response
200/201 — Thành công
| Field | Kiểu | Luôn có? | Mô tả |
|---|
| success | boolean | Có | true khi request thành công |
| message | string | Không | Một số controller truyền message |
| data | object/array | Tùy endpoint | Dữ liệu trả về từ service |
| pagination | object | Với list | Cursor/offset pagination |
{
"success": true,
"data": {
"module": "user",
"endpoint": "/api/v1/users/me/karma"
}
}
Lỗi có thể xảy ra
| HTTP Status | Error Code | Khi nào xảy ra | Cách xử lý ở client |
|---|
| 401 | UNAUTHORIZED | Unauthorized | Login lại hoặc refresh token. |
| 400 | VALIDATION_FAILED | Validation failed | Client sửa field sai. |
| 404 | NOT_FOUND | Resource not found | Refresh dữ liệu. |
| 403 | FORBIDDEN | Forbidden | Ẩn action trong UI. |
| 500 | INTERNAL_SERVER_ERROR | External dependency fail | On-call kiểm tra provider/log. |
Ví dụ lỗi
{
"success": false,
"message": "Validation failed"
}
Ghi chú
- Endpoint đi qua global
apiLimiter. - Idempotency không được đảm bảo trừ khi service có upsert/unique constraint riêng.
- Follow chính mình trả isFollowing:false.
GET /api/v1/users/me/badges
GET Auth required apiLimiter
Endpoint này dùng để badges. [CẦN XÁC NHẬN] response mock. Gọi endpoint này khi client cần thao tác đúng phạm vi module user.
Request
| Header | Giá trị | Bắt buộc | Mô tả |
|---|
| Authorization | Bearer accessToken | Có | JWT access token nếu route protected |
| x-refresh-token | raw refresh token | Không | Refresh token header theo middleware |
| Parameter | Kiểu | Mô tả | Ví dụ |
|---|
| path params | string | Các phần :publicId, :username, :code nếu path có | cm123 |
| query params | string/number | take, after, page, limit hoặc module-specific query | take=20 |
| Field | Kiểu | Bắt buộc | Validation | Mô tả | Ví dụ giá trị |
|---|
| body | object | Không | Theo DTO Zod nếu route có validate() | Payload nghiệp vụ của endpoint | {"content":"Hello"} |
Ví dụ request
curl -X GET http://localhost:3302/api/v1/users/me/badges \
-H "Authorization: Bearer ACCESS_TOKEN" \
-H "Content-Type: application/json"
Response
200/201 — Thành công
| Field | Kiểu | Luôn có? | Mô tả |
|---|
| success | boolean | Có | true khi request thành công |
| message | string | Không | Một số controller truyền message |
| data | object/array | Tùy endpoint | Dữ liệu trả về từ service |
| pagination | object | Với list | Cursor/offset pagination |
{
"success": true,
"data": {
"module": "user",
"endpoint": "/api/v1/users/me/badges"
}
}
Lỗi có thể xảy ra
| HTTP Status | Error Code | Khi nào xảy ra | Cách xử lý ở client |
|---|
| 401 | UNAUTHORIZED | Unauthorized | Login lại hoặc refresh token. |
| 400 | VALIDATION_FAILED | Validation failed | Client sửa field sai. |
| 404 | NOT_FOUND | Resource not found | Refresh dữ liệu. |
| 403 | FORBIDDEN | Forbidden | Ẩn action trong UI. |
| 500 | INTERNAL_SERVER_ERROR | External dependency fail | On-call kiểm tra provider/log. |
Ví dụ lỗi
{
"success": false,
"message": "Validation failed"
}
Ghi chú
- Endpoint đi qua global
apiLimiter. - Idempotency không được đảm bảo trừ khi service có upsert/unique constraint riêng.
- Follow chính mình trả isFollowing:false.
GET /api/v1/user/:username/followers
GET Auth varies apiLimiter
Endpoint này dùng để followers public. Gọi endpoint này khi client cần thao tác đúng phạm vi module user.
Request
| Header | Giá trị | Bắt buộc | Mô tả |
|---|
| Authorization | Bearer accessToken | Không/Tùy route | JWT access token nếu route protected |
| x-refresh-token | raw refresh token | Không | Refresh token header theo middleware |
| Parameter | Kiểu | Mô tả | Ví dụ |
|---|
| path params | string | Các phần :publicId, :username, :code nếu path có | cm123 |
| query params | string/number | take, after, page, limit hoặc module-specific query | take=20 |
| Field | Kiểu | Bắt buộc | Validation | Mô tả | Ví dụ giá trị |
|---|
| body | object | Không | Theo DTO Zod nếu route có validate() | Payload nghiệp vụ của endpoint | {"content":"Hello"} |
Ví dụ request
curl -X GET http://localhost:3302/api/v1/user/alice/followers \
-H "Authorization: Bearer ACCESS_TOKEN" \
-H "Content-Type: application/json"
Response
200/201 — Thành công
| Field | Kiểu | Luôn có? | Mô tả |
|---|
| success | boolean | Có | true khi request thành công |
| message | string | Không | Một số controller truyền message |
| data | object/array | Tùy endpoint | Dữ liệu trả về từ service |
| pagination | object | Với list | Cursor/offset pagination |
{
"success": true,
"data": {
"module": "user",
"endpoint": "/api/v1/user/:username/followers"
}
}
Lỗi có thể xảy ra
| HTTP Status | Error Code | Khi nào xảy ra | Cách xử lý ở client |
|---|
| 401 | UNAUTHORIZED | Unauthorized | Login lại hoặc refresh token. |
| 400 | VALIDATION_FAILED | Validation failed | Client sửa field sai. |
| 404 | NOT_FOUND | Resource not found | Refresh dữ liệu. |
| 403 | FORBIDDEN | Forbidden | Ẩn action trong UI. |
| 500 | INTERNAL_SERVER_ERROR | External dependency fail | On-call kiểm tra provider/log. |
Ví dụ lỗi
{
"success": false,
"message": "Validation failed"
}
Ghi chú
- Endpoint đi qua global
apiLimiter. - Idempotency không được đảm bảo trừ khi service có upsert/unique constraint riêng.
- Follow chính mình trả isFollowing:false.
GET /api/v1/user/:username/following
GET Auth varies apiLimiter
Endpoint này dùng để following public. Gọi endpoint này khi client cần thao tác đúng phạm vi module user.
Request
| Header | Giá trị | Bắt buộc | Mô tả |
|---|
| Authorization | Bearer accessToken | Không/Tùy route | JWT access token nếu route protected |
| x-refresh-token | raw refresh token | Không | Refresh token header theo middleware |
| Parameter | Kiểu | Mô tả | Ví dụ |
|---|
| path params | string | Các phần :publicId, :username, :code nếu path có | cm123 |
| query params | string/number | take, after, page, limit hoặc module-specific query | take=20 |
| Field | Kiểu | Bắt buộc | Validation | Mô tả | Ví dụ giá trị |
|---|
| body | object | Không | Theo DTO Zod nếu route có validate() | Payload nghiệp vụ của endpoint | {"content":"Hello"} |
Ví dụ request
curl -X GET http://localhost:3302/api/v1/user/alice/following \
-H "Authorization: Bearer ACCESS_TOKEN" \
-H "Content-Type: application/json"
Response
200/201 — Thành công
| Field | Kiểu | Luôn có? | Mô tả |
|---|
| success | boolean | Có | true khi request thành công |
| message | string | Không | Một số controller truyền message |
| data | object/array | Tùy endpoint | Dữ liệu trả về từ service |
| pagination | object | Với list | Cursor/offset pagination |
{
"success": true,
"data": {
"module": "user",
"endpoint": "/api/v1/user/:username/following"
}
}
Lỗi có thể xảy ra
| HTTP Status | Error Code | Khi nào xảy ra | Cách xử lý ở client |
|---|
| 401 | UNAUTHORIZED | Unauthorized | Login lại hoặc refresh token. |
| 400 | VALIDATION_FAILED | Validation failed | Client sửa field sai. |
| 404 | NOT_FOUND | Resource not found | Refresh dữ liệu. |
| 403 | FORBIDDEN | Forbidden | Ẩn action trong UI. |
| 500 | INTERNAL_SERVER_ERROR | External dependency fail | On-call kiểm tra provider/log. |
Ví dụ lỗi
{
"success": false,
"message": "Validation failed"
}
Ghi chú
- Endpoint đi qua global
apiLimiter. - Idempotency không được đảm bảo trừ khi service có upsert/unique constraint riêng.
- Follow chính mình trả isFollowing:false.
POST /api/v1/user/:username/follower
POST Auth required apiLimiter
Endpoint này dùng để toggle follow. Gọi endpoint này khi client cần thao tác đúng phạm vi module user.
Request
| Header | Giá trị | Bắt buộc | Mô tả |
|---|
| Authorization | Bearer accessToken | Có | JWT access token nếu route protected |
| x-refresh-token | raw refresh token | Không | Refresh token header theo middleware |
| Parameter | Kiểu | Mô tả | Ví dụ |
|---|
| path params | string | Các phần :publicId, :username, :code nếu path có | cm123 |
| query params | string/number | take, after, page, limit hoặc module-specific query | take=20 |
| Field | Kiểu | Bắt buộc | Validation | Mô tả | Ví dụ giá trị |
|---|
| body | object | Tùy endpoint | Theo DTO Zod nếu route có validate() | Payload nghiệp vụ của endpoint | {"content":"Hello"} |
Ví dụ request
curl -X POST http://localhost:3302/api/v1/user/alice/follower \
-H "Authorization: Bearer ACCESS_TOKEN" \
-H "Content-Type: application/json"
Response
200/201 — Thành công
| Field | Kiểu | Luôn có? | Mô tả |
|---|
| success | boolean | Có | true khi request thành công |
| message | string | Không | Một số controller truyền message |
| data | object/array | Tùy endpoint | Dữ liệu trả về từ service |
| pagination | object | Với list | Cursor/offset pagination |
{
"success": true,
"data": {
"module": "user",
"endpoint": "/api/v1/user/:username/follower"
}
}
Lỗi có thể xảy ra
| HTTP Status | Error Code | Khi nào xảy ra | Cách xử lý ở client |
|---|
| 401 | UNAUTHORIZED | Unauthorized | Login lại hoặc refresh token. |
| 400 | VALIDATION_FAILED | Validation failed | Client sửa field sai. |
| 404 | NOT_FOUND | Resource not found | Refresh dữ liệu. |
| 403 | FORBIDDEN | Forbidden | Ẩn action trong UI. |
| 500 | INTERNAL_SERVER_ERROR | External dependency fail | On-call kiểm tra provider/log. |
Ví dụ lỗi
{
"success": false,
"message": "Validation failed"
}
Ghi chú
- Endpoint đi qua global
apiLimiter. - Idempotency không được đảm bảo trừ khi service có upsert/unique constraint riêng.
- Follow chính mình trả isFollowing:false.