package config

import (
	"os"
)

type Config struct {
	Host       string
	Port       string
	GRPCPort   string
	AdminToken string
	DBPath     string
}

func Load() *Config {
	return &Config{
		Host:       getenv("HOST", "0.0.0.0"),
		Port:       getenv("PORT", "9393"),
		GRPCPort:   getenv("GRPC_PORT", "9394"),
		AdminToken: getenv("ADMIN_TOKEN", "shumengya520"),
		DBPath:     getenv("DB_PATH", "./data/servers.db"),
	}
}

func getenv(key, fallback string) string {
	if v := os.Getenv(key); v != "" {
		return v
	}
	return fallback
}
