Refactor Configuration System to Use Environment Variables
- Removed YAML configuration files for the scraper and web commands, transitioning to an environment-based configuration system. - Updated configuration structs to utilize `env` tags for loading values from `.env` files, enhancing security and flexibility. - Implemented reflection-based parsing for environment variables, ensuring type-safe configuration loading. - Revised documentation to reflect the new configuration approach, including usage examples and best practices for environment variable naming conventions.
This commit is contained in:
+13
-17
@@ -6,27 +6,23 @@ import (
|
||||
|
||||
// Config holds configuration for the web command
|
||||
type Config struct {
|
||||
Server config.ServerConfig `mapstructure:"server"`
|
||||
Database config.DatabaseConfig `mapstructure:"database"`
|
||||
Cache config.CacheConfig `mapstructure:"cache"`
|
||||
Logging config.LoggingConfig `mapstructure:"logging"`
|
||||
RateLimit config.RateLimitConfig `mapstructure:"rate_limiting"`
|
||||
UserAuth AuthConfig `mapstructure:"user_authorization"`
|
||||
CustomerAuth AuthConfig `mapstructure:"customer_authorization"`
|
||||
Assets AssetsConfig `mapstructure:"assets"`
|
||||
Server config.ServerConfig
|
||||
Database config.DatabaseConfig
|
||||
Cache config.CacheConfig
|
||||
Logging config.LoggingConfig
|
||||
RateLimit config.RateLimitConfig
|
||||
Assets config.AssetsConfig
|
||||
UserAuth AuthConfig
|
||||
CustomerAuth AuthConfig
|
||||
}
|
||||
|
||||
type AuthConfig struct {
|
||||
JWT JWTConfig `mapstructure:"jwt"`
|
||||
JWT JWTConfig
|
||||
}
|
||||
|
||||
type JWTConfig struct {
|
||||
AccessSecret string `mapstructure:"access_secret"`
|
||||
RefreshSecret string `mapstructure:"refresh_secret"`
|
||||
AccessExpiresIn int `mapstructure:"access_expires_in"`
|
||||
RefreshExpiresIn int `mapstructure:"refresh_expires_in"`
|
||||
}
|
||||
|
||||
type AssetsConfig struct {
|
||||
FlagsPath string `mapstructure:"flags_path"`
|
||||
AccessSecret string `env:"USER_AUTH_ACCESS_SECRET"`
|
||||
RefreshSecret string `env:"USER_AUTH_REFRESH_SECRET"`
|
||||
AccessExpiresIn int `env:"USER_AUTH_ACCESS_EXPIRES_IN"`
|
||||
RefreshExpiresIn int `env:"USER_AUTH_REFRESH_EXPIRES_IN"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user