16 Commits
Author SHA1 Message Date
Ardeman 211f0154be fix: update default environment mode to local and adjust database configurations 2025-04-24 11:25:36 +08:00
Ardeman 136c4634c8 fix: enable SSL for Redis configuration in debug environment 2025-04-23 19:10:31 +08:00
Ardeman 987ac2fe4a fix: update Redis configuration to use SSL and adjust related settings 2025-04-23 19:09:24 +08:00
Ardeman 02d8a509ff fix: update Redis credentials in staging configuration 2025-04-23 18:45:49 +08:00
Ardeman e29bd7986f fix: update default environment mode to staging and add local configuration file 2025-04-23 18:18:44 +08:00
Ardeman 4bf318a9c2 fix: update PostgreSQL configuration for staging environment 2025-04-23 18:01:55 +08:00
Ardeman 52085a5be0 feat: add staging configuration file with server, database, and OSS settings 2025-04-23 17:52:58 +08:00
Ardeman 21c4c1efba fix: update MinIO endpoint and URLs to use news-cdn.legalgo.id in debug.yaml and production.yaml 2025-04-23 14:50:59 +08:00
Ardeman c17540cc20 fix: update MinIO endpoint and URLs to use crm-cdn.legalgo.id in production.yaml 2025-04-23 14:27:26 +08:00
Ardeman 714b1ff4eb fix: correct public URL formatting in GetPublicURL function 2025-04-23 13:50:41 +08:00
Ardeman abc3ce8d2b fix: update bucket name to 'uploads' in debug.yaml and production.yaml 2025-04-23 13:48:28 +08:00
Ardeman cd1097d3d0 fix: update MinIO endpoint to include the full domain in debug.yaml and production.yaml 2025-04-23 13:39:43 +08:00
Ardeman 52991059c6 fix: update bucket name to legalgonews-production in debug.yaml and production.yaml 2025-04-23 13:17:32 +08:00
Ardeman a7ef3f8ca2 fix: update SSL mode configuration in debug.yaml and NewDB function 2025-04-23 13:11:57 +08:00
Ardeman 6f1ac37915 fix: update redis host configuration in production.yaml 2025-04-23 12:57:06 +08:00
Ardeman e20c63e694 feat: add debug configuration file for server, jwt, postgresql, oss, and redis 2025-04-23 12:50:28 +08:00
9 changed files with 87 additions and 34 deletions
+5 -4
View File
@@ -12,14 +12,15 @@ import (
const ( const (
YAML_PATH = "env/%s" YAML_PATH = "env/%s"
ENV_MODE = "ENV_MODE" ENV_MODE = "ENV_MODE"
DEFAULT_ENV_MODE = "development" DEFAULT_ENV_MODE = "local"
) )
var ( var (
validEnvMode = map[string]struct{}{ validEnvMode = map[string]struct{}{
"local": {}, "local": {},
"development": {}, "staging": {},
"production": {}, "production": {},
"debug": {},
} }
) )
+1 -1
View File
@@ -6,7 +6,7 @@ type Redis struct {
DB int `mapstructure:"db"` DB int `mapstructure:"db"`
Username string `mapstructure:"username"` Username string `mapstructure:"username"`
Password string `mapstructure:"password"` Password string `mapstructure:"password"`
SslMode string `mapstructure:"ssl-mode"` SSL bool `mapstructure:"ssl"`
Debug bool `mapstructure:"debug"` Debug bool `mapstructure:"debug"`
MaxIdleConnectionsInSecond int `mapstructure:"max-idle-connections-in-second"` MaxIdleConnectionsInSecond int `mapstructure:"max-idle-connections-in-second"`
MaxOpenConnectionsInSecond int `mapstructure:"max-open-connections-in-second"` MaxOpenConnectionsInSecond int `mapstructure:"max-open-connections-in-second"`
+2 -1
View File
@@ -15,12 +15,13 @@ type DB struct {
func NewDB(cfg *config.Config) (*DB, error) { func NewDB(cfg *config.Config) (*DB, error) {
dsn := fmt.Sprintf( dsn := fmt.Sprintf(
"host=%s user=%s password=%s dbname=%s port=%v sslmode=disable", "host=%s user=%s password=%s dbname=%s port=%v sslmode=%s",
cfg.Database.Host, cfg.Database.Host,
cfg.Database.Username, cfg.Database.Username,
cfg.Database.Password, cfg.Database.Password,
cfg.Database.DB, cfg.Database.DB,
cfg.Database.Port, cfg.Database.Port,
cfg.Database.SslMode,
) )
if dsn == "" { if dsn == "" {
+6 -6
View File
@@ -15,7 +15,7 @@ postgresql:
db: legalgonews_prod db: legalgonews_prod
username: legalgo_admin username: legalgo_admin
password: "656ogwc0JlLEVQyHnT5RrrYa7762iBQQ" password: "656ogwc0JlLEVQyHnT5RrrYa7762iBQQ"
ssl-mode: disable ssl-mode: require
max-idle-connections-in-second: 600 max-idle-connections-in-second: 600
max-open-connections-in-second: 600 max-open-connections-in-second: 600
connection-max-life-time-in-second: 600 connection-max-life-time-in-second: 600
@@ -24,11 +24,11 @@ postgresql:
oss: oss:
access_key_id: GTK7i3SVy9llQeGH0Htv access_key_id: GTK7i3SVy9llQeGH0Htv
access_key_secret: 2psmKXZFpevA9n5ntSDRMqFBpZuSz32dvtXjYclf access_key_secret: 2psmKXZFpevA9n5ntSDRMqFBpZuSz32dvtXjYclf
endpoint: minio-server-mwbc endpoint: news-cdn.legalgo.id
bucket_name: legalgonews-bucket bucket_name: uploads
log_level: Error log_level: Error
host_url: https://minio-server-mwbc.onrender.com host_url: https://news-cdn.legalgo.id
public_url: https://minio-server-mwbc.onrender.com public_url: https://news-cdn.legalgo.id
redis: redis:
host: singapore-keyvalue.render.com host: singapore-keyvalue.render.com
@@ -36,7 +36,7 @@ redis:
username: red-d046l42dbo4c73ea9iag username: red-d046l42dbo4c73ea9iag
password: 7cZvu08JKuO9MPNxBb97tZCVNj0ZGNp2 password: 7cZvu08JKuO9MPNxBb97tZCVNj0ZGNp2
db: 5 db: 5
ssl: false ssl: true
max-idle-connections-in-second: 600 max-idle-connections-in-second: 600
max-open-connections-in-second: 600 max-open-connections-in-second: 600
connection-max-life-time-in-second: 600 connection-max-life-time-in-second: 600
+43
View File
@@ -0,0 +1,43 @@
server:
base-url: https://api.legalgo.id/core
local-url: http://localhost:3300
port: 3300
jwt:
token:
expires-ttl: 1440
secret: "5Lm25V3Qd7aut8dr4QUxm5PZUrSFs"
postgresql:
host: dpg-d04bi9juibrs73augcc0-a.singapore-postgres.render.com
port: 5432
driver: postgres
db: legalgonews_dev
username: legalgo_admin
password: "5h7DCBR1T8pug6AlbrHXqIDAr9o2vnky"
ssl-mode: require
max-idle-connections-in-second: 600
max-open-connections-in-second: 600
connection-max-life-time-in-second: 600
debug: false
oss:
access_key_id: GTK7i3SVy9llQeGH0Htv
access_key_secret: 2psmKXZFpevA9n5ntSDRMqFBpZuSz32dvtXjYclf
endpoint: news-cdn.legalgo.id
bucket_name: uploads-staging
log_level: Error
host_url: https://news-cdn.legalgo.id
public_url: https://news-cdn.legalgo.id
redis:
host: singapore-keyvalue.render.com
port: 6379
username: red-d04c8k49c44c739ga8dg
password: ItPzniHv94yr8vY4HTrhCfKoibqBh61T
db: 5
ssl: true
max-idle-connections-in-second: 600
max-open-connections-in-second: 600
connection-max-life-time-in-second: 600
debug: false
+5 -6
View File
@@ -24,16 +24,15 @@ postgresql:
oss: oss:
access_key_id: GTK7i3SVy9llQeGH0Htv access_key_id: GTK7i3SVy9llQeGH0Htv
access_key_secret: 2psmKXZFpevA9n5ntSDRMqFBpZuSz32dvtXjYclf access_key_secret: 2psmKXZFpevA9n5ntSDRMqFBpZuSz32dvtXjYclf
endpoint: minio-server-mwbc endpoint: news-cdn.legalgo.id
bucket_name: legalgonews-bucket bucket_name: uploads
log_level: Error log_level: Error
host_url: https://minio-server-mwbc.onrender.com host_url: https://news-cdn.legalgo.id
public_url: https://minio-server-mwbc.onrender.com public_url: https://news-cdn.legalgo.id
redis: redis:
host: localhost host: red-d046l42dbo4c73ea9iag
port: 6379 port: 6379
username: red-d046l42dbo4c73ea9iag
password: 7cZvu08JKuO9MPNxBb97tZCVNj0ZGNp2 password: 7cZvu08JKuO9MPNxBb97tZCVNj0ZGNp2
db: 5 db: 5
ssl: false ssl: false
+13 -13
View File
@@ -9,12 +9,12 @@ jwt:
secret: "5Lm25V3Qd7aut8dr4QUxm5PZUrSFs" secret: "5Lm25V3Qd7aut8dr4QUxm5PZUrSFs"
postgresql: postgresql:
host: 62.72.45.250 host: dpg-d04bi9juibrs73augcc0-a
port: 20826 port: 5432
driver: postgres driver: postgres
db: legalgonews-dev db: legalgonews_dev
username: legalgo_admin username: legalgo_admin
password: "K4K!2Kg7c@KW6H&4A2aBy2dFCRY3Sh" password: "5h7DCBR1T8pug6AlbrHXqIDAr9o2vnky"
ssl-mode: disable ssl-mode: disable
max-idle-connections-in-second: 600 max-idle-connections-in-second: 600
max-open-connections-in-second: 600 max-open-connections-in-second: 600
@@ -22,18 +22,18 @@ postgresql:
debug: false debug: false
oss: oss:
access_key_id: cf9a475e18bc7626cbdbf09709d82a64 access_key_id: GTK7i3SVy9llQeGH0Htv
access_key_secret: 91f3321294d3e23035427a0ecb893ada access_key_secret: 2psmKXZFpevA9n5ntSDRMqFBpZuSz32dvtXjYclf
endpoint: sin1.contabostorage.com endpoint: news-cdn.legalgo.id
bucket_name: legalgonews-dev bucket_name: uploads-staging
log_level: Error log_level: Error
host_url: https://sin1.contabostorage.com host_url: https://news-cdn.legalgo.id
public_url: https://sin1.contabostorage.com/fda98c2228f246f29a7e466b86b3b9e7 public_url: https://news-cdn.legalgo.id
redis: redis:
host: 62.72.45.250 host: red-d04c8k49c44c739ga8dg
port: 26379 port: 6379
password: mDtpsyEW8W26vwLhglpO password: ItPzniHv94yr8vY4HTrhCfKoibqBh61T
db: 5 db: 5
ssl: false ssl: false
max-idle-connections-in-second: 600 max-idle-connections-in-second: 600
+1 -1
View File
@@ -66,7 +66,7 @@ func (r *OssRepositoryImpl) GetPublicURL(fileName string) string {
if fileName == "" { if fileName == "" {
return "" return ""
} }
return fmt.Sprintf("%s:%s%s", r.cfg.GetPublicURL(), r.cfg.GetBucketName(), fileName) return fmt.Sprintf("%s/%s%s", r.cfg.GetPublicURL(), r.cfg.GetBucketName(), fileName)
} }
func (r *OssRepositoryImpl) DeleteObject(ctx context.Context, fileName string) error { func (r *OssRepositoryImpl) DeleteObject(ctx context.Context, fileName string) error {
+11 -2
View File
@@ -1,6 +1,7 @@
package redisaccessor package redisaccessor
import ( import (
"crypto/tls"
"fmt" "fmt"
"legalgo-BE-go/config" "legalgo-BE-go/config"
@@ -16,11 +17,19 @@ func Get() *redis.Client {
func New(cfg *config.Config) *redis.Client { func New(cfg *config.Config) *redis.Client {
addr := fmt.Sprintf("%s:%s", cfg.Redis.Host, cfg.Redis.Port) addr := fmt.Sprintf("%s:%s", cfg.Redis.Host, cfg.Redis.Port)
redisClient = redis.NewClient(&redis.Options{ options := &redis.Options{
Addr: addr, Addr: addr,
Password: cfg.Redis.Password, Password: cfg.Redis.Password,
DB: cfg.Redis.DB, DB: cfg.Redis.DB,
}) }
if cfg.Redis.Username != "" {
options.Username = cfg.Redis.Username
}
if cfg.Redis.SSL {
options.TLSConfig = &tls.Config{}
}
redisClient = redis.NewClient(options)
return redisClient return redisClient
} }