Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

692 B
Raw Blame
import { client } from "@kaneo/libs";
import { HttpError } from "@/lib/http-error";
import {
  ADMIN_WORKSPACES_PAGE_SIZE,
  ADMIN_WORKSPACES_SEARCH_MAX_LENGTH,
} from "./workspace-types";

export async function getAdminWorkspaces(search: string, page: number) {
  const normalizedSearch = search
    .trim()
    .slice(0, ADMIN_WORKSPACES_SEARCH_MAX_LENGTH);
  const response = await client.admin.workspaces.$get({
    query: {
      ...(normalizedSearch ? { search: normalizedSearch } : {}),
      page: String(page + 1),
      limit: String(ADMIN_WORKSPACES_PAGE_SIZE),
    },
  });

  if (!response.ok) {
    throw await HttpError.fromResponse(response);
  }

  return response.json();
}