renommage lassistanoque
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
const (
|
||||
DEFAULT_DB_TYPE = "turso"
|
||||
DEFAULT_DB_URL = "lassistanoque.db"
|
||||
DEFAULT_HTTP_PORT = 3000
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
DatabaseType string
|
||||
DatabaseURL string
|
||||
HttpPort int
|
||||
JWTSecret string
|
||||
}
|
||||
|
||||
var config *Config
|
||||
|
||||
func GetConfig() *Config {
|
||||
|
||||
if config == nil {
|
||||
godotenv.Load()
|
||||
|
||||
databaseType := os.Getenv("LASSISTANOQUE_DB_TYPE")
|
||||
if databaseType == "" {
|
||||
databaseType = DEFAULT_DB_TYPE
|
||||
}
|
||||
databaseURL := os.Getenv("LASSISTANOQUE_DB_URL")
|
||||
if databaseURL == "" {
|
||||
databaseURL = DEFAULT_DB_URL
|
||||
}
|
||||
httpPort, _ := strconv.Atoi(os.Getenv("LASSISTANOQUE_HTTP_PORT"))
|
||||
if httpPort == 0 {
|
||||
httpPort = DEFAULT_HTTP_PORT
|
||||
}
|
||||
jwtsecret := os.Getenv("LASSISTANOQUE_JWT_SECRET")
|
||||
if jwtsecret == "" {
|
||||
log.Fatal("LASSISTANOQUE_JWT_SECRET must be set")
|
||||
}
|
||||
|
||||
config = &Config{
|
||||
DatabaseType: databaseType,
|
||||
DatabaseURL: databaseURL,
|
||||
HttpPort: httpPort,
|
||||
}
|
||||
|
||||
}
|
||||
return config
|
||||
}
|
||||
Reference in New Issue
Block a user