Initial commit. Working login, example UI with prototype and demo, connections to DB and DAV, local and prod setups.

This commit is contained in:
2025-10-12 22:13:19 +01:00
commit 708b741a32
138 changed files with 7797 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
package user
import (
"encoding/json"
"net/http"
"crussell/db"
"crussell/mw"
)
type LoyaltyResponse struct {
Stamps int `json:"stamps"`
ReferralCode string `json:"referralCode"`
}
// GET /api/user/loyalty
func GetLoyaltyHandler(w http.ResponseWriter, r *http.Request) {
userID, _ := mw.GetUserID(r.Context())
var loyalty LoyaltyResponse
err := db.DB.QueryRow(r.Context(), `
SELECT loyalty_stamps, referral_code
FROM users
WHERE id = $1
`, userID).Scan(&loyalty.Stamps, &loyalty.ReferralCode)
if err != nil {
http.Error(w, "failed to get loyalty info", http.StatusInternalServerError)
return
}
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(loyalty)
}