From bf3b2b2f5fdfe4d54226b59ce82378e4a77dc700 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Thu, 14 Aug 2025 22:31:32 +0900 Subject: feat(backend,frontend): Replace hard-coded base path with environment variable --- backend/config/config.go | 54 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 backend/config/config.go (limited to 'backend/config/config.go') diff --git a/backend/config/config.go b/backend/config/config.go new file mode 100644 index 0000000..8211bfd --- /dev/null +++ b/backend/config/config.go @@ -0,0 +1,54 @@ +package config + +import ( + "fmt" + "os" +) + +type Config struct { + DBHost string + DBPort string + DBUser string + DBPassword string + DBName string + BasePath string + IsLocal bool +} + +func NewConfigFromEnv() (*Config, error) { + dbHost, exists := os.LookupEnv("ALBATROSS_DB_HOST") + if !exists { + return nil, fmt.Errorf("ALBATROSS_DB_HOST not set") + } + dbPort, exists := os.LookupEnv("ALBATROSS_DB_PORT") + if !exists { + return nil, fmt.Errorf("ALBATROSS_DB_PORT not set") + } + dbUser, exists := os.LookupEnv("ALBATROSS_DB_USER") + if !exists { + return nil, fmt.Errorf("ALBATROSS_DB_USER not set") + } + dbPassword, exists := os.LookupEnv("ALBATROSS_DB_PASSWORD") + if !exists { + return nil, fmt.Errorf("ALBATROSS_DB_PASSWORD not set") + } + dbName, exists := os.LookupEnv("ALBATROSS_DB_NAME") + if !exists { + return nil, fmt.Errorf("ALBATROSS_DB_NAME not set") + } + basePath, exists := os.LookupEnv("ALBATROSS_BASE_PATH") + if !exists { + return nil, fmt.Errorf("ALBATROSS_BASE_PATH not set") + } + isLocalStr, exists := os.LookupEnv("ALBATROSS_IS_LOCAL") + isLocal := exists && isLocalStr == "1" + return &Config{ + DBHost: dbHost, + DBPort: dbPort, + DBUser: dbUser, + DBPassword: dbPassword, + DBName: dbName, + BasePath: basePath, + IsLocal: isLocal, + }, nil +} -- cgit v1.2.3-70-g09d2