package projects import ( "strconv" db "ttime/internal/database" "github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2/log" ) // GetProject retrieves a specific project by its ID func GetProject(c *fiber.Ctx) error { // Extract the project ID from the request parameters or body projectID := c.Params("projectID") if projectID == "" { log.Info("No project ID provided") return c.Status(400).SendString("No project ID provided") } log.Info("Getting project with ID: ", projectID) // Parse the project ID into an integer projectIDInt, err := strconv.Atoi(projectID) if err != nil { log.Info("Invalid project ID") return c.Status(400).SendString("Invalid project ID") } // Get the project from the database by its ID project, err := db.GetDb(c).GetProject(projectIDInt) if err != nil { log.Info("Error getting project:", err) return c.Status(500).SendString(err.Error()) } // Return the project as JSON log.Info("Returning project: ", project.Name) return c.JSON(project) }