config

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 17, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const Version = "1.0.2"

Version is the current version of the API.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppConfig

type AppConfig struct {
	Env     string `env:"APP_ENV" envDefault:"development"`
	Port    string `env:"PORT" envDefault:"8080"`
	BaseURL string `env:"APP_BASE_URL" envDefault:"http://localhost:8080"`
}

type Config

type Config struct {
	App         AppConfig
	DB          DatabaseConfig
	Redis       RedisConfig
	JWT         JWTConfig
	Log         LogConfig
	Storage     StorageConfig
	RateLimit   RateLimitConfig
	IPRateLimit IPRateLimitConfig
	WhatsApp    WhatsAppConfig
	Webhook     WebhookConfig
	Dashboard   DashboardConfig
}

func Load

func Load() Config

Load carrega as configurações da aplicação.

type DashboardConfig

type DashboardConfig struct {
	Enabled bool `env:"DASHBOARD_ENABLED" envDefault:"true"`
}

type DatabaseConfig

type DatabaseConfig struct {
	URL      string `env:"DATABASE_URL"`
	Host     string `env:"DB_HOST" envDefault:"localhost"`
	Port     int    `env:"DB_PORT" envDefault:"5432"`
	User     string `env:"DB_USER" envDefault:"postgres"`
	Password string `env:"DB_PASSWORD" envDefault:"postgres"`
	Name     string `env:"DB_NAME" envDefault:"postgres"`
	SSLMode  string `env:"DB_SSLMODE" envDefault:"disable"`
}

func (DatabaseConfig) DSN

func (cfg DatabaseConfig) DSN() string

DSN retorna a string de conexão em formato aceito pelo pgxpool.

type IPRateLimitConfig

type IPRateLimitConfig struct {
	Enabled        bool `env:"IP_RATE_LIMIT_ENABLED" envDefault:"true"`
	Requests       int  `env:"IP_RATE_LIMIT_REQUESTS" envDefault:"100"`
	WindowSeconds  int  `env:"IP_RATE_LIMIT_WINDOW_SECONDS" envDefault:"900"`
	SkipPrivateIPs bool `env:"IP_RATE_LIMIT_SKIP_PRIVATE_IPS" envDefault:"true"`
}

type JWTConfig

type JWTConfig struct {
	Secret   string `env:"JWT_SECRET,required"`
	ExpHours int    `env:"JWT_EXP_HOURS" envDefault:"24"`
}

type LogConfig

type LogConfig struct {
	Level string `env:"LOG_LEVEL" envDefault:"debug"`
}

type RateLimitConfig

type RateLimitConfig struct {
	Enabled       bool   `env:"RATE_LIMIT_ENABLED" envDefault:"true"`
	Requests      int    `env:"RATE_LIMIT_REQUESTS" envDefault:"300"`
	WindowSeconds int    `env:"RATE_LIMIT_WINDOW_SECONDS" envDefault:"60"`
	Prefix        string `env:"RATE_LIMIT_PREFIX" envDefault:"ratelimit:api"`
}

type RedisConfig

type RedisConfig struct {
	Addr     string `env:"REDIS_ADDR" envDefault:"localhost:6379"`
	Password string `env:"REDIS_PASSWORD" envDefault:""`
	DB       int    `env:"REDIS_DB" envDefault:"0"`
	Enabled  bool   `env:"REDIS_ENABLED" envDefault:"false"`
}

type StorageConfig

type StorageConfig struct {
	Driver          string `env:"DB_DRIVER" envDefault:"sqlite"`
	DataDir         string `env:"DATA_DIR" envDefault:"/app/data"`
	MediaTTLSeconds int    `env:"MEDIA_TTL_SECONDS" envDefault:"7200"`
}

type WebhookConfig

type WebhookConfig struct {
	Workers int `env:"WEBHOOK_WORKERS" envDefault:"4"`
}

type WhatsAppConfig

type WhatsAppConfig struct {
	SessionKeyEnc string `env:"WHATSAPP_SESSION_KEY_ENC" envDefault:"apime-session-key-change-in-production"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL