init
This commit is contained in:
+19
-28
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
YAML_PATH = "infra/enaklopos.%s"
|
||||
YAML_PATH = "infra/%s"
|
||||
ENV_MODE = "ENV_MODE"
|
||||
DEFAULT_ENV_MODE = "development"
|
||||
)
|
||||
@@ -24,18 +24,11 @@ var (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Server Server `mapstructure:"server"`
|
||||
Database Database `mapstructure:"postgresql"`
|
||||
Jwt Jwt `mapstructure:"jwt"`
|
||||
OSSConfig OSSConfig `mapstructure:"oss"`
|
||||
Midtrans Midtrans `mapstructure:"midtrans"`
|
||||
Brevo Brevo `mapstructure:"brevo"`
|
||||
Email Email `mapstructure:"email"`
|
||||
Withdraw Withdraw `mapstructure:"withdrawal"`
|
||||
Discovery Discovery `mapstructure:"discovery"`
|
||||
Order Order `mapstructure:"order"`
|
||||
FeatureToggle FeatureToggle `mapstructure:"feature_toggle"`
|
||||
LinkQu LinkQu `mapstructure:"linkqu"`
|
||||
Server Server `mapstructure:"server"`
|
||||
Database Database `mapstructure:"postgresql"`
|
||||
Jwt Jwt `mapstructure:"jwt"`
|
||||
Log Log `mapstructure:"log"`
|
||||
S3Config S3Config `mapstructure:"s3"`
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -46,7 +39,7 @@ var (
|
||||
func LoadConfig() *Config {
|
||||
envMode := os.Getenv(ENV_MODE)
|
||||
if _, ok := validEnvMode[envMode]; !ok {
|
||||
envMode = DEFAULT_ENV_MODE // default env mode
|
||||
envMode = DEFAULT_ENV_MODE
|
||||
}
|
||||
cfgFilePath := fmt.Sprintf(YAML_PATH, envMode)
|
||||
|
||||
@@ -72,19 +65,17 @@ func (c *Config) Auth() *AuthConfig {
|
||||
return &AuthConfig{
|
||||
jwtTokenSecret: c.Jwt.Token.Secret,
|
||||
jwtTokenExpiresTTL: c.Jwt.Token.ExpiresTTL,
|
||||
jwtOrderSecret: c.Jwt.TokenOrder.Secret,
|
||||
jwtOrderExpiresTTL: c.Jwt.TokenOrder.ExpiresTTL,
|
||||
jwtSecretResetPassword: JWT{
|
||||
secret: c.Jwt.TokenResetPassword.Secret,
|
||||
expireTTL: c.Jwt.TokenResetPassword.ExpiresTTL,
|
||||
},
|
||||
jwtWithdraw: JWT{
|
||||
secret: c.Jwt.TokenWithdraw.Secret,
|
||||
expireTTL: c.Jwt.TokenWithdraw.ExpiresTTL,
|
||||
},
|
||||
jwtCustomer: JWT{
|
||||
secret: c.Jwt.TokenCustomer.Secret,
|
||||
expireTTL: c.Jwt.TokenCustomer.ExpiresTTL,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Config) LogLevel() string {
|
||||
return c.Log.LogLevel
|
||||
}
|
||||
|
||||
func (c *Config) Port() string {
|
||||
return c.Server.Port
|
||||
}
|
||||
|
||||
func (c *Config) LogFormat() string {
|
||||
return c.Log.LogFormat
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user