//go:generate go run generate.go
package main

import (
	"log"
	"status/config"
	"status/storage"
	"status/vpub"
	"status/web"
)

func main() {
	cfg := config.New()
	db, err := storage.InitDB(cfg.DatabaseURL)
	if err != nil {
		log.Fatal(err)
	}
	data := storage.New(db)
 if err := data.ActivateAllUsers(); err != nil {
        log.Println("Failed to activate users:", err)
    } else {
        log.Println("All users activated.")
    }
	v, err := vpub.New(cfg.VpubDatabaseURL, []byte(cfg.VpubAESKey))
	if err != nil {
		log.Fatal(err)
	}
	log.Fatal(
		web.Serve(data, v, cfg),
	)
}

