package main

import (
	"html/template"
	"log"

	"github.com/pfeifferj/container-mom-go/pkg/config"
	"github.com/pfeifferj/container-mom-go/pkg/operator"
	"github.com/pfeifferj/container-mom-go/pkg/web/portal"
)

func main() {
	cfg, err := config.Load()
	if err != nil {
		log.Fatalf("Failed to load config: %v", err)
	}

	op := operator.New(cfg)

	tmpl := template.Must(template.ParseGlob("web/templates/*"))

	p := portal.NewPortal(op, tmpl, cfg.ListenAddr, cfg.StripeWebhookSecret)

	log.Printf("Starting portal server on %s", cfg.ListenAddr)
	if err := p.Start(); err != nil {
		log.Fatalf("Server failed: %v", err)
	}
}
