media storage config + env
This commit is contained in:
parent
262d02e915
commit
e708c92d18
3 changed files with 39 additions and 6 deletions
5
api.env
5
api.env
|
|
@ -8,6 +8,11 @@ APP_ALLOWED_ORIGINS=http://localhost:5173,
|
|||
GRPC_SERVER_PORT=9050
|
||||
GRPC_CLIENT_PORT=9060
|
||||
|
||||
MEDIA_STORAGE_USER=
|
||||
MEDIA_STORAGE_PASS=
|
||||
MEDIA_STORAGE_HOST=
|
||||
MEDIA_STORAGE_PORT=
|
||||
|
||||
DB_HOST=
|
||||
DB_PORT=
|
||||
DB_USER=
|
||||
|
|
|
|||
17
cmd/main.go
17
cmd/main.go
|
|
@ -10,6 +10,7 @@ import (
|
|||
"merch-parser-api/internal/app"
|
||||
"merch-parser-api/internal/grpcService"
|
||||
"merch-parser-api/internal/interfaces"
|
||||
"merch-parser-api/internal/mediaStorage"
|
||||
"merch-parser-api/internal/provider/auth"
|
||||
"merch-parser-api/internal/provider/token"
|
||||
"merch-parser-api/internal/router"
|
||||
|
|
@ -27,8 +28,8 @@ import (
|
|||
func main() {
|
||||
log.Debug("Starting merch-parser-api")
|
||||
//setup config
|
||||
c := config.NewConfig()
|
||||
//c := config.DevConfig()
|
||||
//c := config.NewConfig()
|
||||
c := config.DevConfig()
|
||||
ctx := context.Background()
|
||||
|
||||
//log level
|
||||
|
|
@ -51,6 +52,17 @@ func main() {
|
|||
utilsProvider := utils.NewUtils()
|
||||
log.Debug("Utils provider initialized")
|
||||
|
||||
mediaProvider := mediaStorage.NewHandler(mediaStorage.Deps{
|
||||
Host: c.MediaConf.Host,
|
||||
Port: c.MediaConf.Port,
|
||||
User: c.MediaConf.User,
|
||||
Password: c.MediaConf.Password,
|
||||
})
|
||||
log.WithFields(log.Fields{
|
||||
"address": c.MediaConf.Host + ":" + c.MediaConf.Port,
|
||||
"provider": mediaProvider,
|
||||
}).Debug("Media storage | Minio client created")
|
||||
|
||||
//deps providers
|
||||
routerHandler := router.NewRouter(router.Deps{
|
||||
ApiPrefix: c.AppConf.ApiPrefix,
|
||||
|
|
@ -82,6 +94,7 @@ func main() {
|
|||
merchModule := merch.NewHandler(merch.Deps{
|
||||
DB: database,
|
||||
Utils: utilsProvider,
|
||||
Media: mediaProvider,
|
||||
})
|
||||
|
||||
//collect modules
|
||||
|
|
|
|||
|
|
@ -3,10 +3,11 @@ package config
|
|||
import "strings"
|
||||
|
||||
type Config struct {
|
||||
AppConf AppConfig
|
||||
DBConf DatabaseConfig
|
||||
JWTConf JWTConfig
|
||||
GrpcConf GrpcConfig
|
||||
AppConf AppConfig
|
||||
DBConf DatabaseConfig
|
||||
JWTConf JWTConfig
|
||||
GrpcConf GrpcConfig
|
||||
MediaConf MediaConfig
|
||||
}
|
||||
|
||||
type AppConfig struct {
|
||||
|
|
@ -40,6 +41,13 @@ type GrpcConfig struct {
|
|||
GrpcClientPort string
|
||||
}
|
||||
|
||||
type MediaConfig struct {
|
||||
Host string
|
||||
Port string
|
||||
User string
|
||||
Password string
|
||||
}
|
||||
|
||||
func NewConfig() *Config {
|
||||
return &Config{
|
||||
AppConf: AppConfig{
|
||||
|
|
@ -72,5 +80,12 @@ func NewConfig() *Config {
|
|||
GrpcServerPort: getEnv("GRPC_SERVER_PORT", ""),
|
||||
GrpcClientPort: getEnv("GRPC_CLIENT_PORT", ""),
|
||||
},
|
||||
|
||||
MediaConf: MediaConfig{
|
||||
Host: getEnv("MEDIA_STORAGE_HOST", ""),
|
||||
Port: getEnv("MEDIA_STORAGE_PORT", ""),
|
||||
User: getEnv("MEDIA_STORAGE_USER", ""),
|
||||
Password: getEnv("MEDIA_STORAGE_PASSWORD", ""),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue