http://localhost:3000/api
- GET
/api/v1/health- Kiểm tra trạng thái ứng dụng
- POST
/api/v1/auth/register- Đăng ký tài khoản mới - POST
/api/v1/auth/login- Đăng nhập - POST
/api/v1/auth/logout- Đăng xuất
- GET
/api/v1/users- Lấy danh sách tất cả users - GET
/api/v1/users/:id- Lấy thông tin user theo ID - POST
/api/v1/users- Tạo user mới - PUT
/api/v1/users/:id- Cập nhật thông tin user - DELETE
/api/v1/users/:id- Xóa user
yarn start:dev- Truy cập: http://localhost:3000/api
- Swagger UI sẽ hiển thị tất cả API endpoints
- Mở section "health"
- Click "GET /api/v1/health"
- Click "Try it out"
- Click "Execute"
- Xem response
-
Mở section "users"
-
Tạo user mới:
- Click "POST /api/v1/users"
- Click "Try it out"
- Nhập data:
{ "email": "test@example.com", "name": "Test User" } - Click "Execute"
-
Lấy danh sách users:
- Click "GET /api/v1/users"
- Click "Try it out"
- Click "Execute"
-
Mở section "auth"
-
Đăng ký:
- Click "POST /api/v1/auth/register"
- Click "Try it out"
- Nhập data:
{ "email": "user@example.com", "password": "password123", "name": "John Doe" } - Click "Execute"
-
Đăng nhập:
- Click "POST /api/v1/auth/login"
- Click "Try it out"
- Nhập data:
{ "email": "user@example.com", "password": "password123" } - Click "Execute"
- Đăng nhập để lấy token
- Click nút "Authorize" ở góc trên bên phải
- Nhập token:
Bearer your-jwt-token-here - Click "Authorize"
- Bây giờ có thể test các protected endpoints
{
"status": "ok",
"timestamp": "2024-01-01T00:00:00.000Z",
"uptime": 123.45,
"environment": "development",
"version": "1.0.0",
"services": {
"database": "connected",
"redis": "connected"
}
}{
"id": 1,
"email": "user@example.com",
"name": "John Doe",
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T00:00:00.000Z"
}{
"message": "Login successful",
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"user": {
"id": 1,
"email": "user@example.com",
"name": "John Doe"
}
}- Test API trực tiếp từ browser
- Không cần Postman hay curl
- Real-time response
- Tự động tạo từ code
- Luôn cập nhật khi code thay đổi
- Type-safe examples
- Có sẵn data mẫu
- Validation tự động
- Error responses đầy đủ
- Bearer token support
- Persistent authorization
- Secure testing
- Kiểm tra database connection
- Xem logs trong terminal
- Đảm bảo PostgreSQL đang chạy
- Kiểm tra URL endpoint
- Đảm bảo ứng dụng đang chạy
- Kiểm tra route configuration
- Kiểm tra JWT token
- Đảm bảo đã login trước
- Kiểm tra token format
- Luôn test API trước khi deploy
- Sử dụng examples có sẵn
- Kiểm tra response status codes
- Lưu token để test protected endpoints
- Xem error messages để debug
- Swagger UI: http://localhost:3000/api
- Health Check: http://localhost:3000/api/v1/health
- API Base URL: http://localhost:3000/api/v1