update
This commit is contained in:
@@ -1,31 +1,31 @@
|
||||
# 🚀 QUICK START - Server Setup
|
||||
|
||||
## Bước 1: Copy file .env
|
||||
## Step 1: Copy .env file
|
||||
```bash
|
||||
cd d:/hotel-booking/server
|
||||
cp .env.example .env
|
||||
```
|
||||
> File .env đã được tạo sẵn với cấu hình mặc định
|
||||
> The .env file has been pre-created with default configuration
|
||||
|
||||
## Bước 2: Tạo Database (nếu chưa có)
|
||||
## Step 2: Create Database (if not exists)
|
||||
```bash
|
||||
# Mở MySQL command line
|
||||
# Open MySQL command line
|
||||
mysql -u root -p
|
||||
|
||||
# Tạo database
|
||||
# Create database
|
||||
CREATE DATABASE hotel_db;
|
||||
|
||||
# Thoát
|
||||
# Exit
|
||||
exit;
|
||||
```
|
||||
|
||||
## Bước 3: Chạy Migrations
|
||||
## Step 3: Run Migrations
|
||||
```bash
|
||||
cd d:/hotel-booking/server
|
||||
npm run migrate
|
||||
```
|
||||
|
||||
Lệnh này sẽ tạo các bảng:
|
||||
This command will create the following tables:
|
||||
- roles
|
||||
- users
|
||||
- refresh_tokens
|
||||
@@ -41,23 +41,23 @@ Lệnh này sẽ tạo các bảng:
|
||||
- password_reset_tokens
|
||||
- reviews
|
||||
|
||||
## Bước 4: (Optional) Seed Data
|
||||
## Step 4: (Optional) Seed Data
|
||||
```bash
|
||||
npm run seed
|
||||
```
|
||||
|
||||
Lệnh này sẽ tạo:
|
||||
This command will create:
|
||||
- 3 roles: admin, staff, customer
|
||||
- Demo users
|
||||
- Demo rooms & room types
|
||||
- Demo bookings
|
||||
|
||||
## Bước 5: Start Server
|
||||
## Step 5: Start Server
|
||||
```bash
|
||||
npm run dev
|
||||
```
|
||||
|
||||
Bạn sẽ thấy:
|
||||
You will see:
|
||||
```
|
||||
✅ Database connection established successfully
|
||||
📊 Database models synced
|
||||
@@ -67,12 +67,12 @@ Bạn sẽ thấy:
|
||||
🏥 Health: http://localhost:3000/health
|
||||
```
|
||||
|
||||
## Bước 6: Test API
|
||||
## Step 6: Test API
|
||||
|
||||
### Health Check
|
||||
Mở browser: http://localhost:3000/health
|
||||
Open browser: http://localhost:3000/health
|
||||
|
||||
### Test Login (sau khi seed data)
|
||||
### Test Login (after seeding data)
|
||||
```bash
|
||||
curl -X POST http://localhost:3000/api/auth/login \
|
||||
-H "Content-Type: application/json" \
|
||||
@@ -81,34 +81,34 @@ curl -X POST http://localhost:3000/api/auth/login \
|
||||
|
||||
## ⚠️ Troubleshooting
|
||||
|
||||
### Lỗi: "Access denied for user 'root'"
|
||||
**Giải pháp:** Sửa DB_PASS trong file `.env`
|
||||
### Error: "Access denied for user 'root'"
|
||||
**Solution:** Update DB_PASS in `.env` file
|
||||
```bash
|
||||
DB_PASS=your_mysql_password
|
||||
```
|
||||
|
||||
### Lỗi: "Unknown database 'hotel_db'"
|
||||
**Giải pháp:** Tạo database thủ công (Bước 2)
|
||||
### Error: "Unknown database 'hotel_db'"
|
||||
**Solution:** Create database manually (Step 2)
|
||||
|
||||
### Lỗi: "Port 3000 already in use"
|
||||
**Giải pháp:** Đổi PORT trong `.env`
|
||||
### Error: "Port 3000 already in use"
|
||||
**Solution:** Change PORT in `.env`
|
||||
```bash
|
||||
PORT=3001
|
||||
```
|
||||
|
||||
### Lỗi: "Cannot find module"
|
||||
**Giải pháp:** Cài lại dependencies
|
||||
### Error: "Cannot find module"
|
||||
**Solution:** Reinstall dependencies
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
## 📝 Next Steps
|
||||
|
||||
1. ✅ Server đang chạy
|
||||
2. ✅ Database đã setup
|
||||
3. ✅ API endpoints sẵn sàng
|
||||
4. 🔜 Test với frontend login form
|
||||
5. 🔜 Implement các API còn lại
|
||||
1. ✅ Server is running
|
||||
2. ✅ Database is set up
|
||||
3. ✅ API endpoints are ready
|
||||
4. 🔜 Test with frontend login form
|
||||
5. 🔜 Implement remaining APIs
|
||||
|
||||
## 🧪 Test với Postman
|
||||
|
||||
@@ -146,14 +146,14 @@ Authorization: Bearer YOUR_ACCESS_TOKEN
|
||||
|
||||
## ✅ Checklist
|
||||
|
||||
- [ ] MySQL đang chạy
|
||||
- [ ] File .env đã tạo và cấu hình đúng
|
||||
- [ ] Database hotel_db đã tạo
|
||||
- [ ] Migrations đã chạy thành công
|
||||
- [ ] Server đang chạy (port 3000)
|
||||
- [ ] Health check trả về 200 OK
|
||||
- [ ] Frontend .env đã có VITE_API_URL=http://localhost:3000
|
||||
- [ ] Frontend đang chạy (port 5173)
|
||||
- [ ] MySQL is running
|
||||
- [ ] .env file has been created and configured correctly
|
||||
- [ ] Database hotel_db has been created
|
||||
- [ ] Migrations have run successfully
|
||||
- [ ] Server is running (port 3000)
|
||||
- [ ] Health check returns 200 OK
|
||||
- [ ] Frontend .env has VITE_API_URL=http://localhost:3000
|
||||
- [ ] Frontend is running (port 5173)
|
||||
|
||||
## 🎯 Ready to Test Login!
|
||||
|
||||
@@ -162,4 +162,4 @@ Authorization: Bearer YOUR_ACCESS_TOKEN
|
||||
3. Login page: http://localhost:5173/login ✅
|
||||
4. API endpoint: http://localhost:3000/api/auth/login ✅
|
||||
|
||||
**Tất cả sẵn sàng!** Giờ có thể test login form từ frontend! 🚀
|
||||
**Everything is ready!** You can now test the login form from the frontend! 🚀
|
||||
|
||||
Reference in New Issue
Block a user