Skip to content

#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere

620 B
Raw Blame
import { http, HttpResponse, delay } from "msw";
import type { Tier } from "@processor/contexts/TierContext";
import { buildDocsNav, docsContentFor } from "@processor/mocks/docs";

function tierFrom(request: Request): Tier {
  const url = new URL(request.url);
  return (url.searchParams.get("tier") ?? "pro") as Tier;
}

export const docsHandlers = [
  http.get("/v1/docs/nav", async () => {
    await delay(120);
    return HttpResponse.json(buildDocsNav());
  }),

  http.get("/v1/docs/content", async ({ request }) => {
    await delay(120);
    return HttpResponse.json(docsContentFor(tierFrom(request)));
  }),
];