парсер

This commit is contained in:
Artem Tsyrulnikov
2026-01-06 21:04:42 +03:00
parent b77e4fd0b6
commit 2c0ae2dfc3
45 changed files with 2202 additions and 51 deletions

View File

@@ -0,0 +1,44 @@
package config
import (
"errors"
"fmt"
"os"
"github.com/TelegramExchange/tgex-parser/pkg/logger"
"github.com/TelegramExchange/tgex-parser/pkg/postgres"
"github.com/joho/godotenv"
"github.com/kelseyhightower/envconfig"
"github.com/TelegramExchange/tgex-parser/internal/controller/worker"
"github.com/TelegramExchange/tgex-parser/pkg/telegram"
)
type HTTP struct {
Addr string `envconfig:"HTTP__ADDR" default:":8080"`
}
type Config struct {
Logger logger.Config
Postgres postgres.Config
Telegram telegram.Config
ChannelWorker worker.ChannelConfig
ViewsWorker worker.ViewsConfig
HTTP HTTP
}
func New() (Config, error) {
var config Config
err := godotenv.Load(".env")
if err != nil && !errors.Is(err, os.ErrNotExist) {
return config, fmt.Errorf("godotenv.Load: %w", err)
}
err = envconfig.Process("", &config)
if err != nil {
return config, fmt.Errorf("envconfig.Process: %w", err)
}
return config, nil
}