config

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const Version = "1.1.0"

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"`
	OutboxWorkers int    `env:"OUTBOX_WORKERS" envDefault:"5"`
}

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
	Sentry      SentryConfig
}

func Load

func Load() Config

Load loads the application configuration.

type DashboardConfig

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

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 returns the connection string in a format accepted by 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 SentryConfig added in v1.2.0

type SentryConfig struct {
	DSN              string  `env:"SENTRY_DSN" envDefault:""`
	Environment      string  `env:"SENTRY_ENVIRONMENT" envDefault:""`
	Release          string  `env:"SENTRY_RELEASE" envDefault:""`
	ServerName       string  `env:"SENTRY_SERVER_NAME" envDefault:""`
	SampleRate       float64 `env:"SENTRY_SAMPLE_RATE" envDefault:"1.0"`
	TracesSampleRate float64 `env:"SENTRY_TRACES_SAMPLE_RATE" envDefault:"0.0"`
}

SentryConfig — without a DSN, the integration stays disabled (no-op).

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"`
	JIDCachePositiveTTLHours  int    `env:"WHATSAPP_JID_CACHE_POSITIVE_TTL_HOURS" envDefault:"24"`
	JIDCacheNegativeTTLDays   int    `env:"WHATSAPP_JID_CACHE_NEGATIVE_TTL_DAYS" envDefault:"7"`
	JIDCachePositiveDBTTLDays int    `env:"WHATSAPP_JID_CACHE_POSITIVE_DB_TTL_DAYS" envDefault:"15"`
}

Jump to

Keyboard shortcuts

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