searchLibraries

tcmts.hub.searchLibraries · #x6tuwggs · term · runs on the server

uses tcmts.hub.hubShare, which uses node:crypto

Search every library's newest mirrored version: by name, words in docs, or a type (:(s: Shape) => number), as tcm find does, or as by says (#z5omemsd).

import { hubShare, libraries, matchLibraries } from "#codebase/tcmts/hub";
import type { LibraryHits } from "#codebase/tcmts/hub";
import { shareNow } from "#codebase/tcmts/share";

export async function searchLibraries(q: string, by?: string): Promise<LibraryHits[]> {
  if (!q.trim()) return [];
  hubShare();
  return matchLibraries(
    shareNow(),
    (await libraries()).filter((l) => l.latest.mount && l.latest.state === "mirrored"),
    q,
    by,
  );
}

uses

used by