Final Project
โปรเจกต์ final-backend-api คือโปรเจกต์รวมท้ายเล่มที่นำเนื้อหาจากบทต่าง ๆ มาประกอบเป็นระบบเดียว
ตำแหน่งไฟล์:
examples/final-backend-api/สิ่งที่อยู่ในโปรเจกต์นี้
Section titled “สิ่งที่อยู่ในโปรเจกต์นี้”- REST API ด้วย Spring Boot
- PostgreSQL และ Spring Data JPA
- Flyway migration
- Register/Login
- BCrypt password hashing
- JWT authentication
- Role
USERและADMIN - Admin user management
- Audit log
- OpenAPI/Swagger UI
- Unit test และ integration test
- Docker Compose
คำสั่งตรวจ test
Section titled “คำสั่งตรวจ test”เข้าไปที่โฟลเดอร์ final project แล้วรัน Gradle wrapper ที่เตรียมไว้:
cd examples/final-backend-api.\gradlew.bat testคำสั่ง build jar
Section titled “คำสั่ง build jar”cd examples/final-backend-api.\gradlew.bat bootJarไฟล์ jar จะถูกสร้างที่:
examples/final-backend-api/build/libs/final-backend-api-1.0.0.jarการทดสอบ API
Section titled “การทดสอบ API”ใช้ไฟล์นี้เปิดใน IntelliJ HTTP Client ได้:
examples/final-backend-api/requests.httpหรือ import Postman collection ได้จาก:
examples/final-backend-api/postman/backend-api.postman_collection.jsonexamples/final-backend-api/postman/backend-api-local.postman_environment.jsonendpoint สำคัญ:
POST /api/v1/auth/registerPOST /api/v1/auth/loginGET /api/v1/auth/meGET /api/v1/admin/usersPATCH /api/v1/admin/users/{id}/rolePATCH /api/v1/admin/users/{id}/statusGET /api/v1/admin/audit-logsGET /swagger-ui.html
หมายเหตุสำหรับมือใหม่
Section titled “หมายเหตุสำหรับมือใหม่”โปรเจกต์นี้ควรอ่านหลังจบบทที่ 40 เพราะเป็นจุดที่ผู้อ่านจะเห็นว่าชิ้นส่วนจากแต่ละบทถูกนำมาประกอบเป็น backend API ที่ใกล้เคียงงานจริงอย่างไร