MUST FIX: - M1: Fixed ignored errors in AI providers (json.Marshal, http.NewRequest, json.Unmarshal) - M2: Template cache — pre-parse all templates once at startup, reuse via getTemplate() - M3: Fixed silent ParseFloat error fallbacks — now returns HTTP 400 on invalid amounts - M4: Wrapped readFile errors with context (fmt.Errorf with %w) - M5: Deleted stale llm.go placeholder file - M6: Renamed utils.New() to utils.NewUUID() for clarity - M7: Validate current_event_id cookie UUID format, prevent tampering SHOULD FIX: - S4: Added utils.Timestamp() helper to replace repeated time.Now().Format() calls - S6: Added request ID middleware for concurrent request log tracing - S7: Increased DB pool from 1 to 4 connections (HTMX concurrency) - S8: Graceful shutdown via http.Server.Shutdown() on SIGINT/SIGTERM - S9: Storage served behind auth middleware with path traversal check COULD FIX: - C2: renderOTPForm uses cached template (not per-request Must) - C3: CSP pinned to unpkg.com/htmx.org@1.9.10 - C4: Added ReadHeaderTimeout, ReadTimeout, WriteTimeout, IdleTimeout - C7: PDF generation auto-adds page breaks when content overflows ADDITIONAL: - Pass config to AI provider constructors (newGeminiProvider, newOpenAIProvider) - Value receivers on geminiProvider/openaiProvider (empty structs) - Added envOrDefault() helper in ai/receipt.go - Session cleanup goroutine started in main.go - Removed duplicate imports and unused html/template from handlers
18 lines
366 B
Go
18 lines
366 B
Go
// Package utils provides common utility functions for ReceiptNext.
|
|
package utils
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// NewUUID generates a new UUID v4 string.
|
|
func NewUUID() string {
|
|
return uuid.New().String()
|
|
}
|
|
|
|
// Timestamp returns the current UTC time formatted as RFC3339.
|
|
func Timestamp() string {
|
|
return time.Now().UTC().Format(time.RFC3339)
|
|
}
|