Working default hours update
This commit is contained in:
+35
-21
@@ -16,7 +16,8 @@ import (
|
||||
"crussell/mw"
|
||||
|
||||
authHandlers "crussell/handlers/auth"
|
||||
userHandlers "crussell/handlers/user"
|
||||
"crussell/handlers/scheduling"
|
||||
"crussell/handlers/user"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -52,6 +53,7 @@ func main() {
|
||||
|
||||
r := chi.NewRouter()
|
||||
|
||||
// --- Middleware ---
|
||||
r.Use(middleware.RequestID) // Add X-Request-ID header
|
||||
r.Use(middleware.RealIP) // Get real IP from headers
|
||||
r.Use(middleware.Logger) // Basic logging
|
||||
@@ -67,40 +69,52 @@ func main() {
|
||||
})
|
||||
})
|
||||
|
||||
// Public auth routes
|
||||
// --- Public auth routes ---
|
||||
r.Post("/api/register", authHandlers.RegisterHandler)
|
||||
r.Post("/api/login", authHandlers.LoginHandler)
|
||||
|
||||
// Protected routes - any authenticated user
|
||||
// --- Protected routes - any authenticated user ---
|
||||
r.Group(func(r chi.Router) {
|
||||
r.Use(mw.RequireAuth)
|
||||
|
||||
// Auth
|
||||
r.Post("/api/refresh-token", authHandlers.RefreshTokenHandler)
|
||||
|
||||
// User profile
|
||||
r.Get("/api/user/profile", userHandlers.GetProfileHandler)
|
||||
r.Put("/api/user/profile", userHandlers.UpdateProfileHandler)
|
||||
r.Delete("/api/user/account", userHandlers.DeleteAccountHandler)
|
||||
r.Get("/api/user/profile", user.GetProfileHandler)
|
||||
r.Put("/api/user/profile", user.UpdateProfileHandler)
|
||||
r.Delete("/api/user/account", user.DeleteAccountHandler)
|
||||
|
||||
// Loyalty
|
||||
r.Get("/api/user/loyalty", userHandlers.GetLoyaltyHandler)
|
||||
r.Get("/api/user/loyalty", user.GetLoyaltyHandler)
|
||||
})
|
||||
|
||||
// Protected routes - verified users only
|
||||
r.Group(func(r chi.Router) {
|
||||
r.Use(mw.RequireAuth)
|
||||
r.Use(mw.RequireVerified)
|
||||
// --- Scheduling routes ---
|
||||
r.Route("/api/scheduling", func(r chi.Router) {
|
||||
|
||||
// Add booking routes, etc.
|
||||
})
|
||||
// Default hours
|
||||
r.Get("/default-hours", scheduling.GetDefaultHours)
|
||||
r.Group(func(r chi.Router) {
|
||||
r.Use(mw.RequireAuth)
|
||||
r.Use(mw.RequireAdmin)
|
||||
r.Put("/default-hours", scheduling.UpdateDefaultHours)
|
||||
})
|
||||
|
||||
// Admin routes
|
||||
r.Group(func(r chi.Router) {
|
||||
r.Use(mw.RequireAuth)
|
||||
r.Use(mw.RequireAdmin)
|
||||
// Exceptional groups
|
||||
r.Get("/exceptional-groups", scheduling.ListExceptionalGroups)
|
||||
r.Group(func(r chi.Router) {
|
||||
r.Use(mw.RequireAuth)
|
||||
r.Use(mw.RequireAdmin)
|
||||
r.Post("/exceptional-groups", scheduling.CreateExceptionalGroup)
|
||||
})
|
||||
|
||||
// Add admin routes
|
||||
// Exceptional applications (assign groups to weeks)
|
||||
r.Get("/exceptional-applications", scheduling.ListExceptionalApplications)
|
||||
r.Group(func(r chi.Router) {
|
||||
r.Use(mw.RequireAuth)
|
||||
r.Use(mw.RequireAdmin)
|
||||
r.Post("/exceptional-applications", scheduling.CreateExceptionalApplication)
|
||||
})
|
||||
|
||||
// Merged working hours by date range
|
||||
r.Get("/working-hours", scheduling.GetWorkingHours)
|
||||
})
|
||||
|
||||
fmt.Println("Server is listening on :8080")
|
||||
|
||||
Reference in New Issue
Block a user