Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/nayalsaurav/Storx/llms.txt

Use this file to discover all available pages before exploring further.

Starring gives you a personal bookmark layer on top of your folder hierarchy. Any file or folder can be starred regardless of where it lives in the tree, and starred items are accessible from the Starred section in the Sidebar without navigating into the folder that contains them.

How Starring Works

Starring is stored as the isStarred boolean column on the files table:
// lib/db/schema.ts
export const files = pgTable("files", {
  // ...
  isStarred: boolean("is_starred").default(false).notNull(),
  // ...
});
The PATCH /api/files/[fileId]/star endpoint toggles isStarred — it reads the current value from the database and flips it, regardless of what the client sends in the body:
// app/api/files/[fileId]/star/route.ts
const [file] = await db
  .select()
  .from(files)
  .where(and(eq(files.id, fileId), eq(files.userId, userId)));

const updatedFiles = await db
  .update(files)
  .set({ isStarred: !file.isStarred })   // server-side toggle
  .where(and(eq(files.id, fileId), eq(files.userId, userId)))
  .returning();

return NextResponse.json(updatedFiles[0], { status: 200 });
Star project assets you reference constantly — design mockups, specification PDFs, or shared reference images — so they are always one click away without drilling into nested folders.

Starring from the Dashboard

The star action is available in the list view FileList component via the dropdown menu. Clicking Star or Unstar calls handleStarToggleWithRefresh in Dashboard, which delegates to handleStarToggle() in useFileOperations and then refreshes the file list:
// hooks/useFileOperations.ts
const handleStarToggle = async (
  fileId: string,
  isCurrentlyStarred: boolean,
) => {
  const response = await fetch(`/api/files/${fileId}/star`, {
    method: "PATCH",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
      isStarred: !isCurrentlyStarred,
      userId,
    }),
  });

  if (response.ok) {
    toast.success(isCurrentlyStarred ? "File unstarred" : "File starred");
    return true;
  }
  // ...
};
// components/dashboard/Dashboard.tsx
const handleStarToggleWithRefresh = async (
  fileId: string,
  isStarred: boolean,
) => {
  const success = await handleStarToggle(fileId, isStarred);
  if (success) fetchFiles(currentFolder); // refreshes the list
};
The client sends isStarred: !isCurrentlyStarred in the request body, but the server ignores that value and always performs a toggle based on the current database value of file.isStarred. The body field is present for reference only and has no effect on the outcome.
In grid view, starred files display a filled yellow Star icon badge overlaid on their thumbnail or file-type icon — but the toggle action is only available in list view’s dropdown menu.

Viewing Starred Files

The Sidebar component contains a Starred navigation button (rendered with a Star icon from Lucide):
// components/dashboard/Sidebar.tsx
<Button
  variant="ghost"
  className="w-full justify-start rounded-lg hover:bg-yellow-50 hover:text-yellow-700 transition-colors"
>
  <Star className="w-4 h-4 mr-3" />
  Starred
</Button>
Clicking Starred in the sidebar navigates to a filtered view of all files where isStarred = true.

Request / Response

PATCH /api/files/{fileId}/star Request body:
{
  "userId": "user_2abc123"
}
Successful response (200 OK) — the full updated database record:
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "design-spec.pdf",
  "size": 204800,
  "type": "application/pdf",
  "fileUrl": "https://ik.imagekit.io/.../design-spec.pdf",
  "thumbnailUrl": null,
  "imagekitFileId": "ik_abc123",
  "userId": "user_2abc123",
  "parentId": null,
  "isFolder": false,
  "isStarred": true,
  "isTrash": false,
  "createdAt": "2024-01-15T10:00:00.000Z",
  "updatedAt": "2024-01-15T12:30:00.000Z"
}
Error responses:
StatusBodyCause
401{ "error": "Unauthorized" }Missing or mismatched session / body userId
400{ "error": "File id is required" }fileId path param is empty
404{ "error": "File not found" }No file with that ID belonging to the user
500{ "error": "Failed to mark the file as starred" }Database error

Build docs developers (and LLMs) love