Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/mackerel_client_deno/deps.ts>mf.mock

Mackerel API Client in Deno
Latest
variable mf.mock
import { mf } from "https://deno.land/x/mackerel_client_deno@v0.7.0/deps.ts";
const { mock } = mf;

Mock a new route, or override an existing handler.

The route uses URLPattern syntax, with the additional extension of (optional) method routing by prefixing with the method, eg. "POST@/user/:id".

The handler function may be asynchronous.

mock("GET@/users/:id", async (_req, params) => {
  const id = parseInt(params["id"]);
  const data = await magicallyGetMyUserData(id);
  return new Response(JSON.stringify(data));
})