Files
bookhoard/internal/router/conflicts.go
T
john-okeefe 6784c25b2e refactor: complete router package migration
Major refactoring milestone - migrate all routes from main.go to internal/router/ package:

## Changes

### cmd/server/main.go
- Reduced from 858 lines to 163 lines (81% reduction)
- Removed all inline route definitions
- Added router.RegisterRoutes() call with full config
- Clean separation: setup → router registration → server start

### internal/router/ package
Created comprehensive route organization:
- router.go: Main router setup and JWT middleware
- auth.go: Authentication routes (login, register, profile, etc.)
- library.go: Library management routes
- device.go: Device registration and management
- sync.go: KOReader/Kobo sync + book matching + WebSocket
- media.go: Media download, shelves, bulk operations
- conflicts.go: Conflict resolution routes
- analytics.go: Analytics API routes
- queue.go: Sync queue management
- opds.go: OPDS feed routes
- frontend.go: SSR pages (/login, /admin, /dashboard, etc.)
- docs.go: Documentation routes
- helpers.go: Template rendering helpers

## Verification
 All 26 guideline checks pass
 Code compiles successfully
 Zero API behavior changes (100% compatible)
 Follows Go standard project layout

## Breaking Changes
None - API compatibility fully maintained
2026-02-06 11:49:28 -05:00

28 lines
869 B
Go

package router
import (
"github.com/labstack/echo-jwt/v4"
)
func registerConflictRoutes(cfg *Config) {
e := cfg.Echo
// JWT middleware for protected routes
jwtMiddleware := echojwt.WithConfig(echojwt.Config{
SigningKey: []byte(cfg.Cfg.JWTSecret),
ContextKey: "user",
})
protected := e.Group("/api", jwtMiddleware)
// Conflict resolution routes
conflicts := protected.Group("/conflicts")
conflicts.GET("", cfg.ConflictHandler.ListConflicts)
conflicts.GET("/:id", cfg.ConflictHandler.GetConflict)
conflicts.POST("/:id/resolve", cfg.ConflictHandler.ResolveConflict)
conflicts.DELETE("/:id", cfg.ConflictHandler.DeleteConflict)
conflicts.POST("/dismiss-all", cfg.ConflictHandler.DismissAllResolved)
conflicts.POST("/bulk-resolve", cfg.ConflictHandler.BulkResolveConflicts)
conflicts.POST("/bulk-dismiss", cfg.ConflictHandler.BulkDismissConflicts)
}