feat(m1): backend scaffold - entries CRUD, start/stop, auth, migrations

This commit is contained in:
2026-04-30 16:35:06 +02:00
parent 4905c6f570
commit 3aa068efd2
19 changed files with 1483 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
package handler
import (
"net/http"
"github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"
"github.com/wotra/wotra/internal/service"
)
// NewRouter builds the full HTTP router.
func NewRouter(authToken string, entrySvc *service.EntryService) http.Handler {
r := chi.NewRouter()
r.Use(middleware.RequestID)
r.Use(middleware.RealIP)
r.Use(middleware.Logger)
r.Use(middleware.Recoverer)
// Unauthenticated
r.Get("/healthz", func(w http.ResponseWriter, r *http.Request) {
writeJSON(w, http.StatusOK, map[string]string{"status": "ok"})
})
// Authenticated API
r.Route("/api", func(r chi.Router) {
r.Use(AuthMiddleware(authToken))
entryH := NewEntryHandler(entrySvc)
entryH.Routes(r)
})
return r
}