server and web app
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
@@ -13,6 +14,7 @@ type Config struct {
|
||||
Content ContentConfig `json:"content"`
|
||||
Web WebConfig `json:"web"`
|
||||
Auth AuthConfig `json:"auth"`
|
||||
Email EmailConfig `json:"email"`
|
||||
LogLevel string `json:"logLevel"`
|
||||
}
|
||||
|
||||
@@ -40,6 +42,12 @@ type AuthConfig struct {
|
||||
PublicOrigin string `json:"publicOrigin"`
|
||||
}
|
||||
|
||||
type EmailConfig struct {
|
||||
SMTPHost string `json:"smtpHost"`
|
||||
SMTPPort int `json:"smtpPort"`
|
||||
From string `json:"from"`
|
||||
}
|
||||
|
||||
func Default() Config {
|
||||
return Config{
|
||||
Server: ServerConfig{
|
||||
@@ -59,6 +67,11 @@ func Default() Config {
|
||||
Auth: AuthConfig{
|
||||
PublicOrigin: "http://localhost:8080",
|
||||
},
|
||||
Email: EmailConfig{
|
||||
SMTPHost: "localhost",
|
||||
SMTPPort: 1025,
|
||||
From: "notifications@cairnquire.local",
|
||||
},
|
||||
LogLevel: "INFO",
|
||||
}
|
||||
}
|
||||
@@ -81,6 +94,13 @@ func Load() (Config, error) {
|
||||
overrideString(&cfg.Web.DistDir, "CAIRNQUIRE_WEB_DIST_DIR")
|
||||
overrideString(&cfg.Web.DevViteURL, "CAIRNQUIRE_DEV_VITE_URL")
|
||||
overrideString(&cfg.Auth.PublicOrigin, "CAIRNQUIRE_PUBLIC_ORIGIN")
|
||||
overrideString(&cfg.Email.SMTPHost, "CAIRNQUIRE_EMAIL_SMTP_HOST")
|
||||
if port := os.Getenv("CAIRNQUIRE_EMAIL_SMTP_PORT"); port != "" {
|
||||
if p, err := strconv.Atoi(port); err == nil {
|
||||
cfg.Email.SMTPPort = p
|
||||
}
|
||||
}
|
||||
overrideString(&cfg.Email.From, "CAIRNQUIRE_EMAIL_FROM")
|
||||
overrideString(&cfg.LogLevel, "CAIRNQUIRE_LOG_LEVEL")
|
||||
|
||||
if cfg.Server.Addr == "" {
|
||||
|
||||
Reference in New Issue
Block a user