refactor: consolidate lang into constants, rename services to email

- Merge lang package into constants (add IsValidLang, ValidateLang, AllLangs)
- Rename internal/services to internal/email for consistency with pdf package
- Rename types to avoid redundancy: EmailService→Service, EmailConfig→Config
- Update all imports and references across codebase
- Delete internal/lang directory (functions moved to constants)
This commit is contained in:
juanatsap
2025-12-06 17:05:17 +00:00
parent 30ed21ff7a
commit c89b67a06d
28 changed files with 241 additions and 290 deletions
+5 -4
View File
@@ -13,9 +13,10 @@ import (
"github.com/joho/godotenv"
"github.com/juanatsap/cv-site/internal/cache"
"github.com/juanatsap/cv-site/internal/config"
c "github.com/juanatsap/cv-site/internal/constants"
"github.com/juanatsap/cv-site/internal/handlers"
"github.com/juanatsap/cv-site/internal/routes"
"github.com/juanatsap/cv-site/internal/services"
"github.com/juanatsap/cv-site/internal/email"
"github.com/juanatsap/cv-site/internal/templates"
)
@@ -51,7 +52,7 @@ func main() {
log.Println("📦 Data cache initialized (en, es)")
// Initialize email service
emailService := services.NewEmailService(&services.EmailConfig{
emailService := email.NewService(&email.Config{
SMTPHost: cfg.Email.SMTPHost,
SMTPPort: cfg.Email.SMTPPort,
SMTPUser: cfg.Email.SMTPUser,
@@ -74,7 +75,7 @@ func main() {
Handler: handler,
ReadTimeout: time.Duration(cfg.Server.ReadTimeout) * time.Second,
WriteTimeout: time.Duration(cfg.Server.WriteTimeout) * time.Second,
IdleTimeout: 120 * time.Second,
IdleTimeout: c.TimeoutIdleConnection,
}
// Start server in goroutine
@@ -104,7 +105,7 @@ func main() {
log.Printf("🛑 Shutdown signal received: %v", sig)
// Create shutdown context with timeout
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), c.TimeoutGracefulShutdown)
defer cancel()
// Attempt graceful shutdown of HTTP server