Refactor configuration management by migrating to a modular config system
- Removed the old `infra.Config` structure and replaced it with a new modular configuration system in `pkg/config`. - Introduced a `Config` struct in `cmd/web/config.go` to hold command-specific configurations. - Updated configuration loading functions to utilize the new `LoadConfig` method with generics for type safety. - Adjusted various initialization functions in `cmd/web/bootstrap.go` and `cmd/web/main.go` to reflect the new configuration structure. - Cleaned up the `config.yaml` by removing obsolete fields and ensuring it aligns with the new configuration schema.
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"tm/pkg/config"
|
||||
)
|
||||
|
||||
// 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"`
|
||||
}
|
||||
|
||||
type AuthConfig struct {
|
||||
JWT JWTConfig `mapstructure:"jwt"`
|
||||
}
|
||||
|
||||
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"`
|
||||
}
|
||||
Reference in New Issue
Block a user