Install LOC guardrails (check-loc.sh, architecture.md, pre-commit hook) and split all 44 files exceeding 500 LOC into domain-focused modules: - consent-service (Go): models, handlers, services, database splits - backend-core (Python): security_api, rbac_api, pdf_service, auth splits - admin-core (TypeScript): 5 page.tsx + sidebar extractions - pitch-deck (TypeScript): 6 slides, 3 UI components, engine.ts splits - voice-service (Python): enhanced_task_orchestrator split Result: 0 violations, 36 exempted (pipeline, tests, pure-data files). Go build verified clean. No behavior changes — pure structural splits. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
35 lines
908 B
Go
35 lines
908 B
Go
package handlers
|
|
|
|
import (
|
|
"context"
|
|
"strconv"
|
|
|
|
"github.com/breakpilot/consent-service/internal/database"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// Handler holds all HTTP handlers
|
|
type Handler struct {
|
|
db *database.DB
|
|
}
|
|
|
|
// New creates a new Handler instance
|
|
func New(db *database.DB) *Handler {
|
|
return &Handler{db: db}
|
|
}
|
|
|
|
// ========================================
|
|
// HELPER FUNCTIONS
|
|
// ========================================
|
|
|
|
func (h *Handler) logAudit(ctx context.Context, userID *uuid.UUID, action, entityType string, entityID *uuid.UUID, details *string, ipAddress, userAgent string) {
|
|
h.db.Pool.Exec(ctx, `
|
|
INSERT INTO consent_audit_log (user_id, action, entity_type, entity_id, details, ip_address, user_agent)
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7)
|
|
`, userID, action, entityType, entityID, details, ipAddress, userAgent)
|
|
}
|
|
|
|
func parseIntFromQuery(s string) (int, error) {
|
|
return strconv.Atoi(s)
|
|
}
|