43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
package initialize
|
|
|
|
import (
|
|
"gitea.pena/PenaSide/common/mongo"
|
|
"github.com/caarlos0/env/v8"
|
|
"github.com/gofiber/fiber/v2"
|
|
"github.com/joho/godotenv"
|
|
"go.uber.org/zap"
|
|
"log"
|
|
)
|
|
|
|
type Config struct {
|
|
KafkaBrokers string `env:"KAFKA_BROKERS,required"`
|
|
KafkaTopicMailNotifier string `env:"KAFKA_TOPIC_MAIL_NOTIFIER,required"`
|
|
CustomerMicroserviceGRPC string `env:"CUSTOMER_MICROSERVICE_GRPC_URL,required"`
|
|
QuizCoreMicroserviceGRPC string `env:"QUIZ_CORE_MICROSERVICE_GRPC_URL,required"`
|
|
External External
|
|
}
|
|
|
|
type External struct {
|
|
MailClientCfg MailClientCfg
|
|
Database mongo.Configuration
|
|
}
|
|
|
|
type MailClientCfg struct {
|
|
ApiURL string `env:"API_URL,required"`
|
|
ApiKey string `env:"MAIL_API_KEY,required"`
|
|
Sender string `env:"MAIL_SENDER,required"`
|
|
FiberClient *fiber.Client
|
|
Logger *zap.Logger
|
|
}
|
|
|
|
func LoadConfig() (*Config, error) {
|
|
if err := godotenv.Load(); err != nil {
|
|
log.Print("No .env file found")
|
|
}
|
|
var config Config
|
|
if err := env.Parse(&config); err != nil {
|
|
return nil, err
|
|
}
|
|
return &config, nil
|
|
}
|