This repository has been archived on 2024-08-30. You can view files and clone it, but cannot push or open issues or pull requests.
RaceBot/main.go
2023-04-15 16:23:34 +07:00

39 lines
789 B
Go

package main
import (
"fmt"
"git.rouggy.com/rouggy/RaceBot/config"
"git.rouggy.com/rouggy/RaceBot/database"
"git.rouggy.com/rouggy/RaceBot/models"
"git.rouggy.com/rouggy/RaceBot/router"
"github.com/gin-gonic/gin"
)
func main() {
config.Load()
database.SQLiteDBConnect()
defer database.GetDB().Close()
SQLiteMigrate()
ServeApplication()
}
func ServeApplication() {
gin.SetMode(gin.ReleaseMode)
r := gin.Default()
router.SetupRoutes(r)
fmt.Println("Server is running on port:", config.HTTPPort)
r.Run(":" + config.HTTPPort)
}
func SQLiteMigrate() {
db := database.GetDB()
if err := db.AutoMigrate(&models.Release{}, &models.Race{}).Error; err != nil {
panic("[Database] Failed migrating database: ")
}
fmt.Println("[Database] Database successfully migrated")
}