mirror of
https://github.com/get-drexa/drive.git
synced 2026-02-02 08:51:16 +00:00
refactor: initial frontend wiring for new api
This commit is contained in:
@@ -54,6 +54,7 @@ func NewHTTPHandler(accountService *Service, authService *auth.Service, db *bun.
|
||||
}
|
||||
|
||||
func (h *HTTPHandler) RegisterRoutes(api fiber.Router) fiber.Router {
|
||||
api.Get("/accounts", h.authMiddleware, h.listAccounts)
|
||||
api.Post("/accounts", h.registerAccount)
|
||||
|
||||
account := api.Group("/accounts/:accountID")
|
||||
@@ -86,6 +87,24 @@ func (h *HTTPHandler) accountMiddleware(c *fiber.Ctx) error {
|
||||
return c.Next()
|
||||
}
|
||||
|
||||
// listAccounts lists all accounts for the authenticated user
|
||||
// @Summary List accounts
|
||||
// @Description Retrieve all accounts for the authenticated user
|
||||
// @Tags accounts
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Success 200 {array} Account "List of accounts for the authenticated user"
|
||||
// @Failure 401 {string} string "Not authenticated"
|
||||
// @Router /accounts [get]
|
||||
func (h *HTTPHandler) listAccounts(c *fiber.Ctx) error {
|
||||
u := reqctx.AuthenticatedUser(c).(*user.User)
|
||||
accounts, err := h.accountService.ListAccounts(c.Context(), h.db, u.ID)
|
||||
if err != nil {
|
||||
return httperr.Internal(err)
|
||||
}
|
||||
return c.JSON(accounts)
|
||||
}
|
||||
|
||||
// getAccount retrieves account information
|
||||
// @Summary Get account
|
||||
// @Description Retrieve account details including storage usage and quota
|
||||
|
||||
Reference in New Issue
Block a user