// // cfg.go // Copyright (C) 2024 veypi // 2025-03-04 16:08:06 // Distributed under terms of the MIT license. // package cfg import ( "os" "time" ) type Options struct { DSN string `json:"dsn"` // Data Source Name DB string `json:"db"` // DB type: mysql, postgres, sqlite RedisAddr string `json:"redis_addr"` ID string `json:"id"` Key string `json:"key"` TokenExpire time.Duration `json:"token_expire"` // Token expiration time in seconds SMS *SMSConfig `json:"sms"` } var Config = &Options{ TokenExpire: time.Minute * 120, ID: getEnv("APPID", "test"), Key: getEnv("APPKEY", "asdfghjklqwertyuiopzxcvbnm1234567890"), DSN: getEnv("DSN", "root:123456@tcp(127.0.0.1:3306)/test?charset=utf8&parseTime=True&loc=Local"), DB: getEnv("DB", "mysql"), SMS: defaultSMS(), } func getEnv(key, defaultValue string) string { v := os.Getenv(key) if v != "" { return v } return defaultValue } type PublicSettings struct { SMS string `json:"sms"` SMSKey string `json:"sms_key"` SMSSecret string `json:"sms_secret"` SMSRegion string `json:"sms_region"` }