Gonçalo Rodrigues b4b7a1381c feat(dashboard): committed goals widget (#32)
* feat(dashboard): committed goals widget

Shows all committed goals on the dashboard with progress bars,
months remaining, saved vs target, and monthly required (green
when on track, red when not). Links to /goals for the full view.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(auth): enable TLS on ingress so Secure session cookie is honoured

BASE_URL was https:// but the ingress had no TLS block, causing the
browser to silently drop the Secure cookie after login. Adding tls: to
the Traefik ingress makes the site serve HTTPS via Traefik's default
cert so cookie and scheme match.

Also adds SeedExtras to seed goals and property/loan data independently
of the transaction-based idempotency guard in SeedAdmin.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Gonçalo Rodrigues <guga@Goncalos-MacBook-Pro.local>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-16 22:27:57 +01:00

68 lines
1.3 KiB
Go

package main
import (
"context"
"log/slog"
"net/http"
"os"
"os/signal"
"syscall"
"homelab/pkg/logger"
"homelab/pkg/mongo"
"homelab/pkg/setup"
"homelab/pkg/trace"
)
func main() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
logger.Init()
slog.Info("starting finance-api")
shutdown := trace.Init(ctx, "finance-api")
defer shutdown()
db, err := mongo.Connect(ctx)
if err != nil {
slog.Error("mongo connect", "err", err)
os.Exit(1)
}
defer db.Close(ctx)
store := NewStore(db)
store.ensureAuthIndexes(ctx)
go SeedAdmin(ctx, store)
go SeedExtras(ctx, store)
secret := os.Getenv("SESSION_SECRET")
if secret == "" {
secret = "dev-secret-change-in-production-32x"
slog.Warn("SESSION_SECRET not set — using insecure default, set it before deploying")
}
handler := NewHandler(store, secret,
os.Getenv("GOOGLE_CLIENT_ID"),
os.Getenv("GOOGLE_CLIENT_SECRET"),
os.Getenv("BASE_URL"),
)
mux := http.NewServeMux()
handler.RegisterRoutes(mux)
srv := setup.Default("finance-api", handler.securityHeaders(mux))
go func() {
sigCh := make(chan os.Signal, 1)
signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM)
<-sigCh
cancel()
}()
if err := srv.Run(ctx); err != nil {
slog.Error("server error", "err", err)
os.Exit(1)
}
}