claptrap-go/main.go

42 lines
735 B
Go
Raw Permalink Normal View History

2024-07-08 18:09:43 +02:00
package main
import (
"flag"
"sebclem/claptrapbot-go/config"
"sebclem/claptrapbot-go/discord"
"sebclem/claptrapbot-go/models"
"time"
ginzap "github.com/gin-contrib/zap"
"github.com/gin-gonic/gin"
)
var (
Token string
)
func init() {
flag.StringVar(&Token, "t", "", "Bot Token")
flag.Parse()
}
func main() {
appConf := config.LoadEnv()
config.InitLogger()
db := config.InitDB(appConf)
models.Init(db)
discord.NewDiscord(appConf.DiscordToken, db)
r := gin.Default()
r.Use(ginzap.Ginzap(config.Logger, time.RFC3339, true))
r.Use(ginzap.RecoveryWithZap(config.Logger, true))
r.GET("/ping", func(c *gin.Context) {
c.JSON(200, gin.H{
"message": "pong",
})
})
r.Run() // listen and serve on 0.0.0.0:8080
}