2023-06-22 09:36:43 +00:00
|
|
|
package models
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/golang-jwt/jwt/v5"
|
2024-02-02 12:15:03 +00:00
|
|
|
"penahub.gitlab.yandexcloud.net/backend/penahub_common/mongo"
|
2023-06-22 09:36:43 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type Config struct {
|
|
|
|
HTTP ConfigurationHTTP
|
|
|
|
GRPC ConfigurationGRPC
|
|
|
|
Service ServiceConfiguration
|
|
|
|
Database mongo.Configuration
|
|
|
|
}
|
|
|
|
|
|
|
|
type ConfigurationHTTP struct {
|
|
|
|
Host string `env:"HTTP_HOST,default=localhost"`
|
|
|
|
Port string `env:"HTTP_PORT,default=8080"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type ConfigurationGRPC struct {
|
|
|
|
Host string `env:"GRPC_HOST,default=localhost"`
|
|
|
|
Port string `env:"GRPC_PORT,default=8081"`
|
|
|
|
Domen string `env:"GRPC_DOMEN,default=https://domen.ru"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type ServiceConfiguration struct {
|
2023-11-26 13:02:01 +00:00
|
|
|
AuthMicroservice AuthMicroserviceConfiguration
|
|
|
|
HubadminMicroservice HubadminMicroserviceConfiguration
|
|
|
|
CurrencyMicroservice CurrencyMicroserviceConfiguration
|
|
|
|
DiscountMicroservice DiscountMicroserviceConfiguration
|
2024-04-25 12:53:33 +00:00
|
|
|
CodewordMicroservice CodewordMicroserviceConfiguration
|
2023-11-26 13:02:01 +00:00
|
|
|
PaymentMicroservice PaymentMicroserviceConfiguration
|
|
|
|
VerificationMicroservice VerificationMicroserviceConfiguration
|
|
|
|
TemplategenMicroserviceURL TemplategenMicroserviceConfiguration
|
|
|
|
JWT JWTConfiguration
|
|
|
|
Kafka KafkaConfiguration
|
2024-02-05 11:13:36 +00:00
|
|
|
Mail MailConfiguration
|
2024-04-25 12:53:33 +00:00
|
|
|
PubKey string `env:"PUBLIC_KEY"`
|
|
|
|
PrivKey string `env:"PRIVATE_KEY"`
|
2023-07-07 01:57:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type KafkaConfiguration struct {
|
|
|
|
Tariff TariffKafkaConfiguration `json:"tariff"`
|
|
|
|
Brokers []string `json:"brokers" env:"KAFKA_BROKERS,required"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type TariffKafkaConfiguration struct {
|
|
|
|
Topic string `json:"topic" env:"KAFKA_TOPIC_TARIFF,required"`
|
2023-06-22 09:36:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type JWTConfiguration struct {
|
|
|
|
PrivateKey string `env:"JWT_PRIVATE_KEY"`
|
|
|
|
PublicKey string `env:"JWT_PUBLIC_KEY,required"`
|
|
|
|
Issuer string `env:"JWT_ISSUER,required"`
|
|
|
|
Audience string `env:"JWT_AUDIENCE,required"`
|
|
|
|
Algorithm jwt.SigningMethodRSA
|
|
|
|
ExpiresIn time.Duration
|
|
|
|
}
|
|
|
|
|
|
|
|
type AuthMicroserviceConfiguration struct {
|
|
|
|
URL AuthMicroserviceURL
|
|
|
|
}
|
|
|
|
|
|
|
|
type HubadminMicroserviceConfiguration struct {
|
|
|
|
URL HubadminMicroserviceURL
|
|
|
|
}
|
|
|
|
|
|
|
|
type CurrencyMicroserviceConfiguration struct {
|
|
|
|
URL CurrencyMicroserviceURL
|
|
|
|
}
|
|
|
|
|
2023-11-26 13:02:01 +00:00
|
|
|
type VerificationMicroserviceConfiguration struct {
|
|
|
|
URL VerificationMicroserviceURL
|
|
|
|
}
|
|
|
|
|
|
|
|
type TemplategenMicroserviceConfiguration struct {
|
|
|
|
URL TemplategenMicroserviceURL
|
|
|
|
}
|
|
|
|
|
2024-04-25 12:53:33 +00:00
|
|
|
type CodewordMicroserviceConfiguration struct {
|
|
|
|
HostGRPC string `env:"CODEWORD_MICROSERVICE_GRPC_HOST,required"`
|
|
|
|
}
|
|
|
|
|
2023-06-22 09:36:43 +00:00
|
|
|
type PaymentMicroserviceConfiguration struct {
|
|
|
|
HostGRPC string `env:"PAYMENT_MICROSERVICE_GRPC_HOST,required"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type DiscountMicroserviceConfiguration struct {
|
|
|
|
HostGRPC string `env:"DISCOUNT_MICROSERVICE_GRPC_HOST,required"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type AuthMicroserviceURL struct {
|
|
|
|
User string `env:"AUTH_MICROSERVICE_USER_URL,required"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type HubadminMicroserviceURL struct {
|
|
|
|
Tariff string `env:"HUBADMIN_MICROSERVICE_TARIFF_URL,required"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type CurrencyMicroserviceURL struct {
|
|
|
|
Translate string `env:"CURRENCY_MICROSERVICE_TRANSLATE_URL,required"`
|
|
|
|
}
|
2023-11-26 13:02:01 +00:00
|
|
|
|
|
|
|
type VerificationMicroserviceURL struct {
|
|
|
|
Verification string `env:"VERIFICATION_MICROSERVICE_USER_URL,required"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type TemplategenMicroserviceURL struct {
|
|
|
|
Templategen string `env:"TEMPLATEGEN_MICROSERVICE_URL,required"`
|
|
|
|
}
|
2024-02-05 11:13:36 +00:00
|
|
|
|
|
|
|
type MailConfiguration struct {
|
2024-02-15 09:03:24 +00:00
|
|
|
ApiUrl string `env:"API_URL,required"`
|
|
|
|
Sender string `env:"MAIL_SENDER,required"`
|
|
|
|
Auth PlainAuth
|
|
|
|
ApiKey string `env:"MAIL_API_KEY,required"`
|
|
|
|
MailAddress string `env:"MAIL_ADDRESS,required"`
|
2024-02-05 11:13:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type PlainAuth struct {
|
|
|
|
Identity string `env:"MAIL_AUTH_IDENTITY"`
|
|
|
|
Username string `env:"MAIL_AUTH_USERNAME,required"`
|
|
|
|
Password string `env:"MAIL_AUTH_PASSWORD,required"`
|
|
|
|
}
|