Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2906,7 +2906,7 @@ const docTemplate = `{
}
}
},
"/user/export": {
"/users/export": {
"get": {
"description": "This endpoint is used to get API keys for a user.",
"produces": [
Expand Down Expand Up @@ -2938,7 +2938,7 @@ const docTemplate = `{
}
}
},
"/user/stats": {
"/users/stats": {
"get": {
"description": "This endpoint is used to geet stats for the current user.",
"produces": [
Expand Down
4 changes: 2 additions & 2 deletions docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2899,7 +2899,7 @@
}
}
},
"/user/export": {
"/users/export": {
"get": {
"description": "This endpoint is used to get API keys for a user.",
"produces": [
Expand Down Expand Up @@ -2931,7 +2931,7 @@
}
}
},
"/user/stats": {
"/users/stats": {
"get": {
"description": "This endpoint is used to geet stats for the current user.",
"produces": [
Expand Down
4 changes: 2 additions & 2 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2085,7 +2085,7 @@ paths:
summary: Revoke a User API Key.
tags:
- User
/user/export:
/users/export:
get:
description: This endpoint is used to get API keys for a user.
produces:
Expand All @@ -2106,7 +2106,7 @@ paths:
summary: Export user data
tags:
- User
/user/stats:
/users/stats:
get:
description: This endpoint is used to geet stats for the current user.
produces:
Expand Down
20 changes: 12 additions & 8 deletions handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,14 @@ func (s *Server) ServeAPI() error {
user.GET("/api-keys", withUser(s.handleUserGetApiKeys))
user.POST("/api-keys", withUser(s.handleUserCreateApiKey))
user.DELETE("/api-keys/:key_or_hash", withUser(s.handleUserRevokeApiKey))
user.GET("/export", withUser(s.handleUserExportData))
user.PUT("/password", withUser(s.handleUserChangePassword))
user.PUT("/address", withUser(s.handleUserChangeAddress))
Comment on lines 145 to 149
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to keep other /user endpoints

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@toastts any news here?

user.GET("/stats", withUser(s.handleGetUserStats))

//move resources to plural users <-- (notice the s!!)
users := e.Group("/users")
users.Use(s.AuthRequired(util.PermLevelUser))
users.GET("/stats", withUser(s.handleUserGetStats))
users.GET("/export", withUser(s.handleUserExportData))

userMiner := user.Group("/miner")
userMiner.POST("/claim", withUser(s.handleUserClaimMiner))
Expand Down Expand Up @@ -1635,8 +1639,8 @@ func (s *Server) handleMakeDeal(c echo.Context, u *util.User) error {
})
}

//from datatransfer.ChannelID and used for swagger docs
//if we don't redefine this here, we'll need to enable parse dependences for swagger and it will take a really long time
// from datatransfer.ChannelID and used for swagger docs
// if we don't redefine this here, we'll need to enable parse dependences for swagger and it will take a really long time
type ChannelIDParam struct {
Initiator string
Responder string
Expand Down Expand Up @@ -3208,16 +3212,16 @@ type userStatsResponse struct {
NumPins int64 `json:"numPins"`
}

// handleGetUserStats godoc
// handleUserGetStats godoc
// @Summary Get stats for the current user
// @Description This endpoint is used to geet stats for the current user.
// @Tags User
// @Produce json
// @Success 200 {object} string
// @Failure 400 {object} util.HttpError
// @Failure 500 {object} util.HttpError
// @Router /user/stats [get]
func (s *Server) handleGetUserStats(c echo.Context, u *util.User) error {
// @Router /users/stats [get]
func (s *Server) handleUserGetStats(c echo.Context, u *util.User) error {
var stats userStatsResponse
if err := s.DB.Raw(` SELECT
(SELECT SUM(size) FROM contents where user_id = ? AND aggregated_in = 0 AND active) as total_size,
Expand Down Expand Up @@ -4169,7 +4173,7 @@ func (s *Server) handleGetStagingZoneForUser(c echo.Context, u *util.User) error
// @Success 200 {object} string
// @Failure 400 {object} util.HttpError
// @Failure 500 {object} util.HttpError
// @Router /user/export [get]
// @Router /users/export [get]
func (s *Server) handleUserExportData(c echo.Context, u *util.User) error {
export, err := s.exportUserData(u.ID)
if err != nil {
Expand Down