update project

This commit is contained in:
2024-11-25 16:10:58 +01:00
parent a6f3325842
commit 958ef12e91
9 changed files with 108 additions and 91 deletions
+11 -14
View File
@@ -4,42 +4,39 @@ import (
"embed"
"encoding/gob"
"gopher-toolbox/app"
"gopher-toolbox/db"
"log/slog"
"ron"
_ "github.com/golang-migrate/migrate/v4/database/postgres"
_ "github.com/golang-migrate/migrate/v4/source/file"
"github.com/gofiber/fiber/v2"
"github.com/zepyrshut/rating-orama/internal/handlers"
"github.com/zepyrshut/rating-orama/internal/repository"
"gopher-toolbox/db"
)
//go:embed database/migrations
var database embed.FS
const version = "0.2.0-beta.20241116-4"
const appName = "rating-orama"
func init() {
gob.Register(map[string]string{})
}
//go:embed database/migrations
var database embed.FS
func main() {
app := app.New(version)
app.Migrate(database)
r := ron.New(func(e *ron.Engine) {
e.Config.LogLevel = slog.LevelDebug
r := fiber.New(fiber.Config{
AppName: appName,
})
dbPool := db.NewPGXPool(app.Database.DataSource)
defer dbPool.Close()
q := repository.NewPGXRepo(dbPool)
h := handlers.New(q, app)
h := handlers.New(app, q)
router(h, r)
slog.Info("server started", "port", "8080", "version", version)
err := r.Run(":8080")
if err != nil {
if err := r.Listen(":8080"); err != nil {
slog.Error("cannot start server", "error", err)
}
}
+3 -5
View File
@@ -1,14 +1,12 @@
package main
import (
"github.com/gofiber/fiber/v2"
"github.com/zepyrshut/rating-orama/internal/handlers"
"ron"
)
func router(h *handlers.Handlers, r *ron.Engine) {
func router(h *handlers.Handlers, r *fiber.App) {
r.GET("/ping", h.Ping)
r.GET("/error", h.Error)
r.GET("/tvshow", h.GetTVShow)
r.Get("/tvshow", h.GetTVShow)
}