package main import ( "context" "log" "net/http" "os" db "github.com/chedius/delivery-tracker/internal/db/sqlc" "github.com/chedius/delivery-tracker/internal/delivery" "github.com/gin-gonic/gin" "github.com/jackc/pgx/v5/pgxpool" "github.com/joho/godotenv" ) func main() { ctx := context.Background() godotenv.Load() dsn := os.Getenv("DATABASE_URL") pool, err := pgxpool.New(ctx, dsn) if err != nil { log.Fatalf("db connect: %v", err) } defer pool.Close() queries := db.New(pool) h := delivery.NewHandler(queries) r := gin.Default() r.GET("/health", func(c *gin.Context) { c.JSON(http.StatusOK, gin.H{"status": "ok"}) }) r.GET("/api/deliveries", h.GetDeliveries) r.GET("/api/deliveries/:id", h.GetDeliveryByID) r.POST("/api/deliveries", h.CreateDelivery) r.PATCH("/api/deliveries/:id", h.UpdateDelivery) r.DELETE("/api/deliveries/:id", h.DeleteDelivery) r.Run(":8080") }