Skip to the content

Capsid menu

app/routes/protocols[.json].ts

22 lines and 1 functions in DrDustinEdwards/dustinedwards-info, at commit 1590ba4 on 2026-10-24. This file on GitHub.

Functions

The functions of protocols[.json].ts
FunctionLinesComplexityCoveredCRAPMutation
loader12 to 241No data: no coverage report in this mapNo data: no coverage report in this mapNo data: no mutants in this code

Imports

It imports app/db/procedures.ts, app/kb/procedures/library.mjs, app/kb/procedures/route.ts, app/lib/context.ts, app/lib/license.mjs, app/lib/markdown-twin.ts, app/lib/seo.ts. No module of this repo imports it.

Source

import { listPublishedLibraryRecords } from "~/db/procedures";
import { getEnv } from "~/lib/context";
import { LICENSE_LINK } from "~/lib/license.mjs";
import { canonicalLink } from "~/lib/markdown-twin";
import { LIBRARY_PATH, libraryItems, libraryRecords } from "~/kb/procedures/library.mjs";
import { PROCEDURES_CACHE_TAG } from "~/kb/procedures/route";
import { LICENSE_URL, SHARED_CACHE_CONTROL, SITE_ORIGIN } from "~/lib/seo";

import type { Route } from "./+types/protocols[.json]";

/** The library as JSON, for the filter state in the query string (the page's own parameters). */
export async function loader({ request, context }: Route.LoaderArgs) {
  const items = libraryItems(await listPublishedLibraryRecords(getEnv(context)));
  const rows = libraryRecords(items, new URL(request.url).searchParams, SITE_ORIGIN);
  return new Response(`${JSON.stringify({ license: LICENSE_URL, count: rows.length, protocols: rows }, null, 2)}\n`, {
    headers: {
      "content-type": "application/json; charset=utf-8",
      "cache-control": SHARED_CACHE_CONTROL,
      "cache-tag": PROCEDURES_CACHE_TAG,
      "x-robots-tag": "noindex",
      link: `${canonicalLink(LIBRARY_PATH)}, ${LICENSE_LINK}`,
    },
  });
}