- Go (Golang)
- Fiber (Go Web Framework)
- PostgreSQL
- Go 1.22 or later
- Docker
- Makefile
-
Clone the repository:
git clone https://github.com/isd-sgcu/cutu2025-backend.git cd cutu2025-backend
-
Setup environment:
cp .env.example .env # Edit .env file with your configurations
-
Install dependencies:
go mod download
Start Database:
docker-compose up -d
Run Server:
make server # Normal mode
Re-create doc
swag init -g cmd/main.go # Normal mode
Endpoint: POST /api/users/register
Request Format (multipart/form-data):
name: string
phone: string (format: 0812345678)
province: string
school: string
firstInterest: string
secondInterest: string
thirdInterest: string
other...
Success Response (201):
{
"accessToken": "string",
"userId": "string"
}
Endpoint: GET /api/users
Permissions: Bearer Token (Staff/Admin)
Query Parameters:
name
: Filter by name
Success Response (200):
[
{
"id": "string",
"name": "string",
"phone": "+66812345678",
"province": "Bangkok",
"school": "Chulalongkorn University"
}
]
Endpoint: GET /api/users/{id}
Permissions: Bearer Token
Success Response (200):
{
"id": "string",
"uid": "string",
"name": "string",
"phone": "+66812345678",
"province": "Bangkok",
"school": "Chulalongkorn University",
"firstInterest": "Technology",
"secondInterest": "Design",
"thirdInterest": "Business"
}
Endpoint: PATCH /api/users/{id}
Permissions: Bearer Token
Request Body:
{
"email": "[email protected]",
"birthDate": "2000-01-01T00:00:00Z",
"school": "New University"
}
Success Response: 204 No Content
Endpoint: POST /api/users/qr/{id}
Permissions: Bearer Token (Staff/Admin)
Success Response (200):
{
"id": "string",
"name": "string",
"lastEntered": "2024-01-01T12:00:00Z"
}
Error Response (400):
{
"error": "User has already entered",
"message": "2024-01-01 12:00:00 +0000 UTC"
}
Endpoint: PATCH /api/users/addstaff/{phone}
Permissions: Bearer Token (Admin)
Success Response: 204 No Content
type User struct {
ID string `json:"id"`
UID string `json:"uid"`
Name string `json:"name"`
Email *string `json:"email"`
Phone string `json:"phone"`
BirthDate *time.Time `json:"birthDate"`
Role Role `json:"role"`
Province string `json:"province"`
School string `json:"school"`
SelectedSources []string `json:"selectedSources"`
OtherSource *string `json:"otherSource"`
FirstInterest string `json:"firstInterest"`
SecondInterest string `json:"secondInterest"`
ThirdInterest string `json:"thirdInterest"`
Objective string `json:"objective"`
RegisteredAt *time.Time `json:"registerAt"`
LastEntered *time.Time `json:"lastEntered"`
}
User Roles:
type Role string
const (
Member Role = "member"
Staff Role = "staff"
Admin Role = "admin"
)
400 Bad Request:
{
"error": "Invalid phone number format"
}
401 Unauthorized:
{
"error": "Missing or invalid token"
}
403 Forbidden:
{
"error": "Insufficient permissions"
}
404 Not Found:
{
"error": "User not found"
}
500 Internal Server Error:
{
"error": "Database connection failed"
}