package routes import ( "log/slog" "net/http" "orbits-server/internal/server/api/response" "orbits-server/internal/server/database" "github.com/gin-gonic/gin" "gorm.io/gorm" ) func RegisterApiRoutes(api *gin.RouterGroup /* env runtime.Environment,*/, db *gorm.DB) { // prefix: api // Display the information on what is going on at the moment api.GET("/command", func(c *gin.Context) { state, err := database.GetState(db) if err != nil { slog.Error("unable to determine state", "error", err) c.JSON(http.StatusInternalServerError, response.BasicResponse{ Msg: response.IntErrMes, }) return } c.JSON(http.StatusOK, response.BasicResponse{ Msg: response.OkMes, Data: state, }) }) api.PATCH("/command", func(c *gin.Context) { }) // define a route to check what is registered api.GET("/available", func(c *gin.Context) { files, err := database.GetFiles(db) if err != nil { slog.Error("failed to retrieve available files", "error", err) c.JSON(http.StatusInternalServerError, response.BasicResponse{ Msg: response.IntErrMes, }) return } c.JSON(http.StatusOK, response.BasicResponse{ Msg: response.OkMes, Data: files, }) }) }