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:
17
src/main.go
17
src/main.go
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user