package config

import "fmt"

var (
	APP_PORT,
	REDIS_DB,
	REDIS_TIMEOUT,
	GRACEFULL_TIMEOUT int

	// DB
	DB_HOST,
	DB_USER,
	DB_PASSWORD,
	DB_NAME,
	DB_PORT,
	REDIS_PASSWORD,
	REDIS_ADDR,
	REDIS_USERNAME,
	SALT_SECURITY string
)

func InitEnv() {
	DB_HOST = GetOrDefault("DB_HOST", "localhost")
	DB_USER = GetOrDefault("DB_USER", "")
	DB_PASSWORD = GetOrDefault("DB_PASSWORD", "")
	DB_NAME = GetOrDefault("DB_NAME", "")
	DB_PORT = GetOrDefault("DB_PORT", "")

	SALT_SECURITY = GetOrDefault("SALT_SECURITY", "legalgo")

	APP_PORT = GetOrDefault("APP_PORT", 3000)
	GRACEFULL_TIMEOUT = GetOrDefault("GRACEFULL_TIMEOUT", 10)

	REDIS_DB = GetOrDefault("REDIS_DB", 0)
	REDIS_PASSWORD = GetOrDefault("REDIS_PASSWORD", "")
	REDIS_ADDR = fmt.Sprintf("%s:%s", GetOrDefault("REDIS_HOST", "localhost"), GetOrDefault("REDIS_PORT", "6379"))
	REDIS_USERNAME = GetOrDefault("REDIS_USERNAME", "")
	REDIS_TIMEOUT = GetOrDefault("REDIS_TIMEOUT", 60)
}
