Rename app to Lemma

This commit is contained in:
2024-12-19 23:59:27 +01:00
parent 5598c0861d
commit b6b4c01f0e
70 changed files with 262 additions and 263 deletions

View File

@@ -2,8 +2,8 @@ package app
import (
"fmt"
"novamd/internal/logging"
"novamd/internal/secrets"
"lemma/internal/logging"
"lemma/internal/secrets"
"os"
"strconv"
"strings"
@@ -32,7 +32,7 @@ type Config struct {
// DefaultConfig returns a new Config instance with default values
func DefaultConfig() *Config {
return &Config{
DBPath: "./novamd.db",
DBPath: "./lemma.db",
WorkDir: "./data",
StaticPath: "../app/dist",
Port: "8080",
@@ -45,12 +45,12 @@ func DefaultConfig() *Config {
// validate checks if the configuration is valid
func (c *Config) validate() error {
if c.AdminEmail == "" || c.AdminPassword == "" {
return fmt.Errorf("NOVAMD_ADMIN_EMAIL and NOVAMD_ADMIN_PASSWORD must be set")
return fmt.Errorf("LEMMA_ADMIN_EMAIL and LEMMA_ADMIN_PASSWORD must be set")
}
// Validate encryption key
if err := secrets.ValidateKey(c.EncryptionKey); err != nil {
return fmt.Errorf("invalid NOVAMD_ENCRYPTION_KEY: %w", err)
return fmt.Errorf("invalid LEMMA_ENCRYPTION_KEY: %w", err)
}
return nil
@@ -70,52 +70,52 @@ func (c *Config) Redact() *Config {
func LoadConfig() (*Config, error) {
config := DefaultConfig()
if env := os.Getenv("NOVAMD_ENV"); env != "" {
if env := os.Getenv("LEMMA_ENV"); env != "" {
config.IsDevelopment = env == "development"
}
if dbPath := os.Getenv("NOVAMD_DB_PATH"); dbPath != "" {
if dbPath := os.Getenv("LEMMA_DB_PATH"); dbPath != "" {
config.DBPath = dbPath
}
if workDir := os.Getenv("NOVAMD_WORKDIR"); workDir != "" {
if workDir := os.Getenv("LEMMA_WORKDIR"); workDir != "" {
config.WorkDir = workDir
}
if staticPath := os.Getenv("NOVAMD_STATIC_PATH"); staticPath != "" {
if staticPath := os.Getenv("LEMMA_STATIC_PATH"); staticPath != "" {
config.StaticPath = staticPath
}
if port := os.Getenv("NOVAMD_PORT"); port != "" {
if port := os.Getenv("LEMMA_PORT"); port != "" {
config.Port = port
}
if rootURL := os.Getenv("NOVAMD_ROOT_URL"); rootURL != "" {
if rootURL := os.Getenv("LEMMA_ROOT_URL"); rootURL != "" {
config.RootURL = rootURL
}
if domain := os.Getenv("NOVAMD_DOMAIN"); domain != "" {
if domain := os.Getenv("LEMMA_DOMAIN"); domain != "" {
config.Domain = domain
}
if corsOrigins := os.Getenv("NOVAMD_CORS_ORIGINS"); corsOrigins != "" {
if corsOrigins := os.Getenv("LEMMA_CORS_ORIGINS"); corsOrigins != "" {
config.CORSOrigins = strings.Split(corsOrigins, ",")
}
config.AdminEmail = os.Getenv("NOVAMD_ADMIN_EMAIL")
config.AdminPassword = os.Getenv("NOVAMD_ADMIN_PASSWORD")
config.EncryptionKey = os.Getenv("NOVAMD_ENCRYPTION_KEY")
config.JWTSigningKey = os.Getenv("NOVAMD_JWT_SIGNING_KEY")
config.AdminEmail = os.Getenv("LEMMA_ADMIN_EMAIL")
config.AdminPassword = os.Getenv("LEMMA_ADMIN_PASSWORD")
config.EncryptionKey = os.Getenv("LEMMA_ENCRYPTION_KEY")
config.JWTSigningKey = os.Getenv("LEMMA_JWT_SIGNING_KEY")
// Configure rate limiting
if reqStr := os.Getenv("NOVAMD_RATE_LIMIT_REQUESTS"); reqStr != "" {
if reqStr := os.Getenv("LEMMA_RATE_LIMIT_REQUESTS"); reqStr != "" {
parsed, err := strconv.Atoi(reqStr)
if err == nil {
config.RateLimitRequests = parsed
}
}
if windowStr := os.Getenv("NOVAMD_RATE_LIMIT_WINDOW"); windowStr != "" {
if windowStr := os.Getenv("LEMMA_RATE_LIMIT_WINDOW"); windowStr != "" {
parsed, err := time.ParseDuration(windowStr)
if err == nil {
config.RateLimitWindow = parsed
@@ -123,7 +123,7 @@ func LoadConfig() (*Config, error) {
}
// Configure log level, if isDevelopment is set, default to debug
if logLevel := os.Getenv("NOVAMD_LOG_LEVEL"); logLevel != "" {
if logLevel := os.Getenv("LEMMA_LOG_LEVEL"); logLevel != "" {
parsed := logging.ParseLogLevel(logLevel)
config.LogLevel = parsed
} else if config.IsDevelopment {