This commit is contained in:
aditya.siregar
2025-07-18 20:10:29 +07:00
parent 1bceae010b
commit 4f5950543e
511 changed files with 24132 additions and 34137 deletions
-9
View File
@@ -1,9 +0,0 @@
package config
type Brevo struct {
APIKey string `mapstructure:"api_key"`
}
func (b *Brevo) GetApiKey() string {
return b.APIKey
}
+19 -28
View File
@@ -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
}
+2 -38
View File
@@ -3,13 +3,8 @@ package config
import "time"
type AuthConfig struct {
jwtTokenExpiresTTL int
jwtTokenSecret string
jwtOrderSecret string
jwtOrderExpiresTTL int
jwtSecretResetPassword JWT
jwtWithdraw JWT
jwtCustomer JWT
jwtTokenExpiresTTL int
jwtTokenSecret string
}
type JWT struct {
@@ -21,38 +16,7 @@ func (c *AuthConfig) AccessTokenSecret() string {
return c.jwtTokenSecret
}
func (c *AuthConfig) AccessTokenOrderSecret() string {
return c.jwtOrderSecret
}
func (c *AuthConfig) AccessTokenCustomerSecret() string {
return c.jwtCustomer.secret
}
func (c *AuthConfig) AccessTokenWithdrawSecret() string {
return c.jwtWithdraw.secret
}
func (c *AuthConfig) AccessTokenWithdrawExpire() time.Time {
duration := time.Duration(c.jwtWithdraw.expireTTL)
return time.Now().UTC().Add(time.Minute * duration)
}
func (c *AuthConfig) AccessTokenOrderExpiresDate() time.Time {
duration := time.Duration(c.jwtOrderExpiresTTL)
return time.Now().UTC().Add(time.Minute * duration)
}
func (c *AuthConfig) AccessTokenExpiresDate() time.Time {
duration := time.Duration(c.jwtTokenExpiresTTL)
return time.Now().UTC().Add(time.Minute * duration)
}
func (c *AuthConfig) AccessTokenResetPasswordSecret() string {
return c.jwtSecretResetPassword.secret
}
func (c *AuthConfig) AccessTokenResetPasswordExpire() time.Time {
duration := time.Duration(c.jwtSecretResetPassword.expireTTL)
return time.Now().UTC().Add(time.Minute * duration)
}
-17
View File
@@ -1,17 +0,0 @@
package config
type Discovery struct {
ExploreDestinations []ExploreDestination `mapstructure:"explore_destinations"`
ExploreRegions []ExploreRegion `mapstructure:"explore_regions"`
}
type ExploreDestinations []ExploreDestination
type ExploreDestination struct {
Name string `mapstructure:"name"`
ImageURL string `mapstructure:"image_url"`
}
type ExploreRegion struct {
Name string `mapstructure:"name"`
}
-34
View File
@@ -1,34 +0,0 @@
package config
type Email struct {
Sender string `mapstructure:"sender"`
SenderCustomer string `mapstructure:"sender_customer"`
CustomReceiver string `mapstructure:"custom_receiver"`
ResetPassword EmailConfig `mapstructure:"reset_password"`
}
type EmailConfig struct {
Subject string `mapstructure:"subject"`
OpeningWord string `mapstructure:"opening_word"`
Link string `mapstructure:"link"`
Notes string `mapstructure:"note"`
ClosingWord string `mapstructure:"closing_word"`
TemplateName string `mapstructure:"template_name"`
TemplatePath string `mapstructure:"template_path"`
TemplatePathCustomer string `mapstructure:"template_path_customer"`
}
type EmailMemberRequestActionConfig struct {
TemplateName string `mapstructure:"template_name"`
TemplatePath string `mapstructure:"template_path"`
Subject string `mapstructure:"subject"`
Content string `mapstructure:"content"`
}
func (e *Email) GetSender() string {
return e.Sender
}
func (e *Email) GetCustomReceiver() string {
return e.CustomReceiver
}
+1 -5
View File
@@ -1,11 +1,7 @@
package config
type Jwt struct {
Token Token `mapstructure:"token"`
TokenOrder Token `mapstructure:"token-order"`
TokenResetPassword Token `mapstructure:"token-reset-password"`
TokenWithdraw Token `mapstructure:"token-withdraw"`
TokenCustomer Token `mapstructure:"token-customer"`
Token Token `mapstructure:"token"`
}
type Token struct {
-49
View File
@@ -1,49 +0,0 @@
package config
type LinkQu struct {
BaseURL string `mapstructure:"base_url"`
ClientID string `mapstructure:"client_id"`
ClientSecret string `mapstructure:"client_secret"`
SignatureKey string `mapstructure:"signature_key"`
Username string `mapstructure:"username"`
PIN string `mapstructure:"pin"`
CallbackURL string `mapstructure:"callback_url"`
}
type LinkQuConfig interface {
LinkQuBaseURL() string
LinkQuClientID() string
LinkQuClientSecret() string
LinkQuSignatureKey() string
LinkQuUsername() string
LinkQuPIN() string
LinkQuCallbackURL() string
}
func (c *LinkQu) LinkQuBaseURL() string {
return c.BaseURL
}
func (c *LinkQu) LinkQuClientID() string {
return c.ClientID
}
func (c *LinkQu) LinkQuClientSecret() string {
return c.ClientSecret
}
func (c *LinkQu) LinkQuSignatureKey() string {
return c.SignatureKey
}
func (c *LinkQu) LinkQuUsername() string {
return c.Username
}
func (c *LinkQu) LinkQuPIN() string {
return c.PIN
}
func (c *LinkQu) LinkQuCallbackURL() string {
return c.CallbackURL
}
+6
View File
@@ -0,0 +1,6 @@
package config
type Log struct {
LogFormat string `mapstructure:"log_format"`
LogLevel string `mapstructure:"log_level"`
}
-9
View File
@@ -1,9 +0,0 @@
package config
type FeatureToggle struct {
LoggerEnabled bool `mapstructure:"logger_enabled"`
}
func (f *FeatureToggle) IsLoggerEnabled() bool {
return f.LoggerEnabled
}
-25
View File
@@ -1,25 +0,0 @@
package config
type Midtrans struct {
Serverkey string `mapstructure:"server_key"`
Clientkey string `mapstructure:"client_key"`
Env int `mapstructure:"env"`
}
type MidtransConfig interface {
MidtransServerKey() string
MidtransClientKey() string
MidtranEnvType() int
}
func (c *Midtrans) MidtransServerKey() string {
return c.Serverkey
}
func (c *Midtrans) MidtransClientKey() string {
return c.Clientkey
}
func (c *Midtrans) MidtranEnvType() int {
return c.Env
}
-12
View File
@@ -1,12 +0,0 @@
package config
type Order struct {
Fee float64 `mapstructure:"fee"`
}
func (w *Order) GetOrderFee(source string) float64 {
if source == "POS" {
return 0
}
return w.Fee
}
+8 -8
View File
@@ -1,6 +1,6 @@
package config
type OSSConfig struct {
type S3Config struct {
AccessKeyID string `mapstructure:"access_key_id"`
AccessKeySecret string `mapstructure:"access_key_secret"`
Endpoint string `mapstructure:"endpoint"`
@@ -10,30 +10,30 @@ type OSSConfig struct {
HostURL string `mapstructure:"host_url"`
}
func (c OSSConfig) GetAccessKeyID() string {
func (c S3Config) GetAccessKeyID() string {
return c.AccessKeyID
}
func (c OSSConfig) GetAccessKeySecret() string {
func (c S3Config) GetAccessKeySecret() string {
return c.AccessKeySecret
}
func (c OSSConfig) GetEndpoint() string {
func (c S3Config) GetEndpoint() string {
return c.Endpoint
}
func (c OSSConfig) GetBucketName() string {
func (c S3Config) GetBucketName() string {
return c.BucketName
}
func (c OSSConfig) GetLogLevel() string {
func (c S3Config) GetLogLevel() string {
return c.LogLevel
}
func (c OSSConfig) GetHostURL() string {
func (c S3Config) GetHostURL() string {
return c.HostURL
}
func (c OSSConfig) GetPhotoFolder() string {
func (c S3Config) GetPhotoFolder() string {
return c.PhotoFolder
}
-1
View File
@@ -1 +0,0 @@
package config
-9
View File
@@ -1,9 +0,0 @@
package config
type Withdraw struct {
PlatformFee int64 `mapstructure:"platform_fee"`
}
func (w *Withdraw) GetPlatformFee() int64 {
return w.PlatformFee
}