From 981c4efb5fc413aecc4f1b71e80a0d596cd571c4 Mon Sep 17 00:00:00 2001 From: Punarv Pawade Date: Sun, 31 Mar 2024 16:06:14 +0530 Subject: [PATCH] cleanup --- api/api.go | 2 ++ api/github/github.go | 54 -------------------------------------------- api/github/types.go | 13 ----------- 3 files changed, 2 insertions(+), 67 deletions(-) delete mode 100644 api/github/github.go delete mode 100644 api/github/types.go diff --git a/api/api.go b/api/api.go index 569f0f7..c64093b 100644 --- a/api/api.go +++ b/api/api.go @@ -2,6 +2,7 @@ package api import ( "github.com/GitSplit-org/backend/api/projects" + "github.com/GitSplit-org/backend/api/user" "github.com/gin-gonic/gin" ) @@ -9,5 +10,6 @@ func ApplyRoutes(r *gin.Engine) { api := r.Group("") { projects.ApplyRoutes(api) + user.ApplyRoutes(api) } } diff --git a/api/github/github.go b/api/github/github.go deleted file mode 100644 index 679b3c0..0000000 --- a/api/github/github.go +++ /dev/null @@ -1,54 +0,0 @@ -package github - -import ( - "fmt" - "net/http" - - "github.com/GitSplit-org/backend/config/dbconfig" - "github.com/GitSplit-org/backend/models" - "github.com/gin-gonic/gin" -) - -func ApplyRoutes(r *gin.RouterGroup) { - api := r.Group("/github") - { - api.POST("", AddProject) - api.GET("", GetAllProjects) - } -} - -func AddProject(c *gin.Context) { - var req AddProjectRequest - if err := c.BindJSON(&req); err != nil { - fmt.Println("error", err) - return - } - db := dbconfig.GetDb() - var project models.Project - project.Name = req.Name - project.Url = req.Url - project.Description = req.Description - err := db.Create(&project).Error - if err != nil { - fmt.Println("error", err.Error()) - return - } - c.JSON(http.StatusOK, gin.H{ - "message": "project added successfully", - "data": project, - }) -} - -func GetAllProjects(c *gin.Context) { - db := dbconfig.GetDb() - var projects []models.Project - err := db.Model(&models.Project{}).Find(&projects).Error - if err != nil { - fmt.Println("error", err.Error()) - return - } - c.JSON(http.StatusOK, gin.H{ - "message": "projects fetched successfully", - "data": projects, - }) -} diff --git a/api/github/types.go b/api/github/types.go deleted file mode 100644 index 130240e..0000000 --- a/api/github/types.go +++ /dev/null @@ -1,13 +0,0 @@ -package github - -type AddProjectRequest struct { - Name string `json:"name"` - Url string `json:"url"` - Description string `json:"description"` -} - -type Project struct { - Name string `json:"name"` - Url string `json:"url"` - Description string `json:"description"` -}