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_SERVER_PORT=9050
|
||||||
GRPC_CLIENT_PORT=9060
|
GRPC_CLIENT_PORT=9060
|
||||||
|
|
||||||
|
MEDIA_STORAGE_USER=
|
||||||
|
MEDIA_STORAGE_PASS=
|
||||||
|
MEDIA_STORAGE_HOST=
|
||||||
|
MEDIA_STORAGE_PORT=
|
||||||
|
|
||||||
DB_HOST=
|
DB_HOST=
|
||||||
DB_PORT=
|
DB_PORT=
|
||||||
DB_USER=
|
DB_USER=
|
||||||
|
|
|
||||||
17
cmd/main.go
17
cmd/main.go
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"merch-parser-api/internal/app"
|
"merch-parser-api/internal/app"
|
||||||
"merch-parser-api/internal/grpcService"
|
"merch-parser-api/internal/grpcService"
|
||||||
"merch-parser-api/internal/interfaces"
|
"merch-parser-api/internal/interfaces"
|
||||||
|
"merch-parser-api/internal/mediaStorage"
|
||||||
"merch-parser-api/internal/provider/auth"
|
"merch-parser-api/internal/provider/auth"
|
||||||
"merch-parser-api/internal/provider/token"
|
"merch-parser-api/internal/provider/token"
|
||||||
"merch-parser-api/internal/router"
|
"merch-parser-api/internal/router"
|
||||||
|
|
@ -27,8 +28,8 @@ import (
|
||||||
func main() {
|
func main() {
|
||||||
log.Debug("Starting merch-parser-api")
|
log.Debug("Starting merch-parser-api")
|
||||||
//setup config
|
//setup config
|
||||||
c := config.NewConfig()
|
//c := config.NewConfig()
|
||||||
//c := config.DevConfig()
|
c := config.DevConfig()
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
//log level
|
//log level
|
||||||
|
|
@ -51,6 +52,17 @@ func main() {
|
||||||
utilsProvider := utils.NewUtils()
|
utilsProvider := utils.NewUtils()
|
||||||
log.Debug("Utils provider initialized")
|
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
|
//deps providers
|
||||||
routerHandler := router.NewRouter(router.Deps{
|
routerHandler := router.NewRouter(router.Deps{
|
||||||
ApiPrefix: c.AppConf.ApiPrefix,
|
ApiPrefix: c.AppConf.ApiPrefix,
|
||||||
|
|
@ -82,6 +94,7 @@ func main() {
|
||||||
merchModule := merch.NewHandler(merch.Deps{
|
merchModule := merch.NewHandler(merch.Deps{
|
||||||
DB: database,
|
DB: database,
|
||||||
Utils: utilsProvider,
|
Utils: utilsProvider,
|
||||||
|
Media: mediaProvider,
|
||||||
})
|
})
|
||||||
|
|
||||||
//collect modules
|
//collect modules
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,11 @@ package config
|
||||||
import "strings"
|
import "strings"
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
AppConf AppConfig
|
AppConf AppConfig
|
||||||
DBConf DatabaseConfig
|
DBConf DatabaseConfig
|
||||||
JWTConf JWTConfig
|
JWTConf JWTConfig
|
||||||
GrpcConf GrpcConfig
|
GrpcConf GrpcConfig
|
||||||
|
MediaConf MediaConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
type AppConfig struct {
|
type AppConfig struct {
|
||||||
|
|
@ -40,6 +41,13 @@ type GrpcConfig struct {
|
||||||
GrpcClientPort string
|
GrpcClientPort string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type MediaConfig struct {
|
||||||
|
Host string
|
||||||
|
Port string
|
||||||
|
User string
|
||||||
|
Password string
|
||||||
|
}
|
||||||
|
|
||||||
func NewConfig() *Config {
|
func NewConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
AppConf: AppConfig{
|
AppConf: AppConfig{
|
||||||
|
|
@ -72,5 +80,12 @@ func NewConfig() *Config {
|
||||||
GrpcServerPort: getEnv("GRPC_SERVER_PORT", ""),
|
GrpcServerPort: getEnv("GRPC_SERVER_PORT", ""),
|
||||||
GrpcClientPort: getEnv("GRPC_CLIENT_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