feat: add query param to include dir path in query

This commit is contained in:
2025-12-05 00:38:05 +00:00
parent 1bedafd3de
commit 3ea12cf51a
4 changed files with 64 additions and 10 deletions

View File

@@ -16,12 +16,13 @@ const (
)
type DirectoryInfo struct {
Kind string `json:"kind"`
ID string `json:"id"`
Name string `json:"name"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
DeletedAt *time.Time `json:"deletedAt,omitempty"`
Kind string `json:"kind"`
ID string `json:"id"`
Path virtualfs.Path `json:"path,omitempty"`
Name string `json:"name"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
DeletedAt *time.Time `json:"deletedAt,omitempty"`
}
type createDirectoryRequest struct {
@@ -93,6 +94,7 @@ func (h *HTTPHandler) createDirectory(c *fiber.Ctx) error {
func (h *HTTPHandler) fetchDirectory(c *fiber.Ctx) error {
node := mustCurrentDirectoryNode(c)
i := DirectoryInfo{
Kind: DirItemKindDirectory,
ID: node.PublicID,
@@ -101,6 +103,16 @@ func (h *HTTPHandler) fetchDirectory(c *fiber.Ctx) error {
UpdatedAt: node.UpdatedAt,
DeletedAt: node.DeletedAt,
}
include := c.Query("include")
if include == "path" {
p, err := h.vfs.RealPath(c.Context(), h.db, node)
if err != nil {
return httperr.Internal(err)
}
i.Path = p
}
return c.JSON(i)
}