aggiunto e testato quasar apps

This commit is contained in:
fabio
2026-03-01 20:42:27 +01:00
parent cdcacadb5f
commit 66a3cc7cdb
73 changed files with 1559 additions and 389 deletions

View File

@@ -2,6 +2,7 @@ package http
import (
"fmt"
"path/filepath"
"trustcontact/internal/config"
"trustcontact/internal/controllers"
httpmw "trustcontact/internal/http/middleware"
@@ -28,9 +29,10 @@ func RegisterRoutes(app *fiber.App, store *session.Store, database *gorm.DB, cfg
return fmt.Errorf("init auth service: %w", err)
}
authController := controllers.NewAuthController(authService)
usersService := services.NewUsersService(database)
usersController := controllers.NewUsersController(usersService)
adminController := controllers.NewAdminController()
privateSPADir := filepath.FromSlash("quasar/private_section/dist/spa")
privateController := controllers.NewPrivateController(privateSPADir)
adminSPADir := filepath.FromSlash("quasar/admin_section/dist/spa")
adminController := controllers.NewAdminController(adminSPADir)
app.Get("/healthz", func(c *fiber.Ctx) error {
return c.SendStatus(fiber.StatusOK)
@@ -49,20 +51,32 @@ func RegisterRoutes(app *fiber.App, store *session.Store, database *gorm.DB, cfg
app.Get("/reset-password", authController.ShowResetPassword)
app.Post("/reset-password", authController.ResetPassword)
app.Get("/forbidden", authController.ShowForbidden)
app.Get("/welcome", httpmw.RequireAuth(), authController.ShowWelcome)
app.Post("/preferences/lang", httpmw.RequireAuth(), authController.UpdateLanguage)
app.Post("/preferences/theme", httpmw.RequireAuth(), authController.UpdateTheme)
// Quasar admin SPA assets are emitted with absolute paths (/assets, /icons, /favicon.ico).
// Protect them with the same auth/admin middleware used by /admin.
app.Use("/assets", httpmw.RequireAuth(), httpmw.RequireAdmin())
app.Use("/icons", httpmw.RequireAuth(), httpmw.RequireAdmin())
app.Get("/favicon.ico", httpmw.RequireAuth(), httpmw.RequireAdmin(), privateController.Favicon)
app.Static("/assets", filepath.Join(privateSPADir, "assets"))
app.Static("/icons", filepath.Join(privateSPADir, "icons"))
private := app.Group("/private", httpmw.RequireAuth(), httpmw.RequireAdmin())
private.Get("/", func(c *fiber.Ctx) error {
return c.Redirect("/admin/users")
})
private.Get("/", privateController.Dashboard)
private.Get("/*", privateController.Fallback)
// Quasar admin SPA assets are emitted with absolute paths (/assets, /icons, /favicon.ico).
// Protect them with the same auth/admin middleware used by /admin.
app.Use("/assets", httpmw.RequireAuth(), httpmw.RequireAdmin())
app.Use("/icons", httpmw.RequireAuth(), httpmw.RequireAdmin())
app.Get("/favicon.ico", httpmw.RequireAuth(), httpmw.RequireAdmin(), adminController.Favicon)
app.Static("/assets", filepath.Join(adminSPADir, "assets"))
app.Static("/icons", filepath.Join(adminSPADir, "icons"))
admin := app.Group("/admin", httpmw.RequireAuth(), httpmw.RequireAdmin())
admin.Get("/", adminController.Dashboard)
admin.Get("/users", usersController.Index)
admin.Get("/users/table", usersController.Table)
admin.Get("/users/:id/modal", usersController.Modal)
admin.Get("/*", adminController.Fallback)
return nil
}