Base Flutter Project

This commit is contained in:
2021-01-06 14:36:09 -05:00
parent 5b068f607c
commit 24c4adf910
79 changed files with 1891 additions and 174 deletions

21
internal/config/config.go Normal file
View File

@@ -0,0 +1,21 @@
package config
import (
"reichard.io/imagini/internal/db"
"gorm.io/gorm"
)
type ServerConfig struct {
db *gorm.DB
settings *Settings
}
func NewConfig() {
loadedSettings := loadSettings()
loadedDB := db.OpenDB(&loadedSettings)
newConfig := &Config {
settings: &loadedSettings,
db: &loadedDB,
}
}

View File

@@ -0,0 +1,32 @@
package config
import (
"os"
)
type Settings struct {
DBType string
DBName string
DBPassword string
DataPath string
ConfigPath string
JWTSecret string
}
func loadSettings() *Settings {
return &Settings{
DBType: getEnv("DATABASE_TYPE", "SQLite"),
DBName: getEnv("DATABASE_NAME", "imagini"),
DBPassword: getEnv("DATABASE_PASSWORD", ""),
ConfigPath: getEnv("CONFIG_PATH", "/config"),
DataPath: getEnv("DATA_PATH", "/data"),
JWTSecret: getEnv("JWT_SECRET", "58b9340c0472cf045db226bc445966524e780cd38bc3dd707afce80c95d4de6f"),
}
}
func getEnv(key, fallback string) string {
if value, ok := os.LookupEnv(key); ok {
return value
}
return fallback
}