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"
)
// ─── Project Handlers ──────────────────────────────────────────────────────────
// ListProjects handles GET /api/projects.
func (h *Handler) ListProjects(w http.ResponseWriter, r *http.Request) {
projects := h.ProjectStore.List()
if projects == nil {
projects = []models.Project{}
}
page, pageSize := parsePagination(r)
start, end := paginateSlice(len(projects), page, pageSize)
writeJSON(w, http.StatusOK, models.PaginatedResponse{
Data: projects[start:end],
TotalCount: h.ProjectStore.Count(),
Page: page,
PageSize: pageSize,
HasMore: end < len(projects),
})
}