CUB-127: implement Control Center CRUD API in Go
Some checks failed
Dev Build / build-test (pull_request) Failing after 11m6s
Dev Build / build-test (push) Successful in 1m54s

This commit is contained in:
2026-05-06 17:29:44 -04:00
parent ab19a7ccde
commit cce3e061a7
16 changed files with 1523 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
package handler
import (
"net/http"
"code.cubecraftcreations.com/CubeCraft-Creations/Control-Center/go-backend/internal/models"
)
// ─── Task Handlers ─────────────────────────────────────────────────────────────
// ListTasks handles GET /api/tasks.
func (h *Handler) ListTasks(w http.ResponseWriter, r *http.Request) {
tasks := h.TaskStore.ListRecent()
if tasks == nil {
tasks = []models.Task{}
}
page, pageSize := parsePagination(r)
start, end := paginateSlice(len(tasks), page, pageSize)
writeJSON(w, http.StatusOK, models.PaginatedResponse{
Data: tasks[start:end],
TotalCount: h.TaskStore.Count(),
Page: page,
PageSize: pageSize,
HasMore: end < len(tasks),
})
}