feat: add services and separate further

This commit is contained in:
2026-04-29 13:25:38 +02:00
parent 6c28aea655
commit 8f6b1efea0
16 changed files with 318 additions and 168 deletions
+36
View File
@@ -0,0 +1,36 @@
package routes
import (
"log/slog"
"net/http"
"orbits-server/internal/server/api/assets"
"orbits-server/internal/server/service"
"github.com/gin-gonic/gin"
"gorm.io/gorm"
)
func RegisterCtrlRoutes(api *gin.RouterGroup, db *gorm.DB) {
ctrlService := service.NewControlService(db)
// define the control route on the api
// /api/control
ctrl := api.Group("/control")
// Display the information on what is going on at the moment
ctrl.GET("/command", func(c *gin.Context) {
command, err := ctrlService.ListLatestCommand()
if err != nil {
slog.Error("unable to determine state", "error", err)
assets.InternalErrorResponse(c)
return
}
c.JSON(http.StatusOK, assets.BasicResponse{
Msg: assets.OkMes,
Data: command,
})
})
ctrl.PATCH("/command", func(c *gin.Context) {
})
}