Enhance project functionality: add email template, implement email sending, and improve table management routes

The table management in the database does currently not work
This commit is contained in:
Jonas Hahn
2025-08-25 16:43:24 +02:00
parent f5e5d5632d
commit a1cba9c4eb
10 changed files with 230 additions and 10 deletions

View File

@@ -9,6 +9,7 @@ import (
"github.com/gin-contrib/sessions"
"github.com/gin-contrib/sessions/cookie"
"github.com/gin-gonic/gin"
"github.com/joho/godotenv"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
)
@@ -34,9 +35,17 @@ const (
func main() {
log.SetFlags(log.LstdFlags | log.Lshortfile)
var err error
err = godotenv.Load()
if err != nil {
log.Fatal("Error loading .env file")
}
// Get the listening port
port := os.Getenv("APP_PORT")
port = strconv.Itoa(defaultPort)
if port == "" {
port = strconv.Itoa(defaultPort)
}
// Set the base URL
baseURL = os.Getenv("APP_BASE_URL")
@@ -45,7 +54,6 @@ func main() {
}
// Open connection to SQLite
var err error
db, err = gorm.Open(sqlite.Open("qrank.db"), &gorm.Config{})
if err != nil {
lg.Fatal("sqlite connect:", err)
@@ -84,8 +92,9 @@ func main() {
authorized.POST("/enter", postEnter)
// QR-prepped table routes
authorized.GET("/table/:tableSlug", getEnter)
authorized.POST("/table/:tableSlug", postEnter)
authorized.GET("/table/:tableSlug", getTable)
authorized.POST("/table/:tableSlug", postTable)
authorized.POST("/table/:tableSlug/reset", postTableReset)
authorized.GET("/history", getHistory)
authorized.GET("/leaderboard", getLeaderboard)