Skip to content

Commit

Permalink
Update project routes (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
juancwu authored Nov 28, 2024
2 parents 5975fb8 + a38507e commit dc6c716
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions backend/internal/server/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,11 @@ func (s *Server) setupProjectRoutes() {

s.apiV1.POST("/projects/:id/comments", s.handleCreateProjectComment, middleware.ValidateRequestBody(reflect.TypeOf(CreateProjectCommentRequest{})))
s.apiV1.GET("/projects/:id/comments", s.handleListProjectComments)
s.apiV1.DELETE("/comments/:id", s.handleDeleteProjectComment)
s.apiV1.DELETE("/projects/comments/:id", s.handleDeleteProjectComment)

s.apiV1.POST("/projects/:id/links", s.handleCreateProjectLink, middleware.ValidateRequestBody(reflect.TypeOf(CreateProjectLinkRequest{})))
s.apiV1.GET("/projects/:id/links", s.handleListProjectLinks)
s.apiV1.DELETE("/links/:id", s.handleDeleteProjectLink)
s.apiV1.DELETE("/projects/links/:id", s.handleDeleteProjectLink)

s.apiV1.POST("/projects/:id/tags", s.handleAddProjectTag, middleware.ValidateRequestBody(reflect.TypeOf(AddProjectTagRequest{})))
s.apiV1.GET("/projects/:id/tags", s.handleListProjectTags)
Expand Down
20 changes: 10 additions & 10 deletions backend/internal/server/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (s *Server) handleDeleteProject(c echo.Context) error {
}

func (s *Server) handleCreateProjectFile(c echo.Context) error {
projectID, err := validateUUID(c.Param("project_id"), "project")
projectID, err := validateUUID(c.Param("id"), "project")
if err != nil {
return err
}
Expand Down Expand Up @@ -141,7 +141,7 @@ func (s *Server) handleCreateProjectFile(c echo.Context) error {
}

func (s *Server) handleListProjectFiles(c echo.Context) error {
projectID, err := validateUUID(c.Param("project_id"), "project")
projectID, err := validateUUID(c.Param("id"), "project")
if err != nil {
return err
}
Expand Down Expand Up @@ -171,7 +171,7 @@ func (s *Server) handleDeleteProjectFile(c echo.Context) error {
}

func (s *Server) handleCreateProjectComment(c echo.Context) error {
projectID, err := validateUUID(c.Param("project_id"), "project")
projectID, err := validateUUID(c.Param("id"), "project")
if err != nil {
return err
}
Expand Down Expand Up @@ -208,7 +208,7 @@ func (s *Server) handleCreateProjectComment(c echo.Context) error {
}

func (s *Server) handleListProjectComments(c echo.Context) error {
projectID, err := validateUUID(c.Param("project_id"), "project")
projectID, err := validateUUID(c.Param("id"), "project")
if err != nil {
return err
}
Expand All @@ -229,7 +229,7 @@ func (s *Server) handleDeleteProjectComment(c echo.Context) error {
}

queries := db.New(s.DBPool)

// First check if the comment exists using a direct query
var exists bool
err = s.DBPool.QueryRow(context.Background(), "SELECT EXISTS(SELECT 1 FROM project_comments WHERE id = $1)", commentID).Scan(&exists)
Expand All @@ -249,7 +249,7 @@ func (s *Server) handleDeleteProjectComment(c echo.Context) error {
}

func (s *Server) handleCreateProjectLink(c echo.Context) error {
projectID, err := validateUUID(c.Param("project_id"), "project")
projectID, err := validateUUID(c.Param("id"), "project")
if err != nil {
return err
}
Expand Down Expand Up @@ -281,7 +281,7 @@ func (s *Server) handleCreateProjectLink(c echo.Context) error {
}

func (s *Server) handleListProjectLinks(c echo.Context) error {
projectID, err := validateUUID(c.Param("project_id"), "project")
projectID, err := validateUUID(c.Param("id"), "project")
if err != nil {
return err
}
Expand Down Expand Up @@ -311,7 +311,7 @@ func (s *Server) handleDeleteProjectLink(c echo.Context) error {
}

func (s *Server) handleAddProjectTag(c echo.Context) error {
projectID, err := validateUUID(c.Param("project_id"), "project")
projectID, err := validateUUID(c.Param("id"), "project")
if err != nil {
return err
}
Expand Down Expand Up @@ -348,7 +348,7 @@ func (s *Server) handleAddProjectTag(c echo.Context) error {
}

func (s *Server) handleListProjectTags(c echo.Context) error {
projectID, err := validateUUID(c.Param("project_id"), "project")
projectID, err := validateUUID(c.Param("id"), "project")
if err != nil {
return err
}
Expand All @@ -363,7 +363,7 @@ func (s *Server) handleListProjectTags(c echo.Context) error {
}

func (s *Server) handleDeleteProjectTag(c echo.Context) error {
projectID, err := validateUUID(c.Param("project_id"), "project")
projectID, err := validateUUID(c.Param("id"), "project")
if err != nil {
return err
}
Expand Down

0 comments on commit dc6c716

Please sign in to comment.