[]previous and next page

Running code after the response: after()

after(task) queues work for the request that is being handled.

For agentsUpdated

after(task) queues work for the request that is being handled. The task runs once the response body has ended (or through the platform's waitUntil when the adapter provides one). The response does not wait for it. A task that fails is reported to instrumentation with the phase after, and nothing reaches the response or stops the process (a sink or a hook that throws while reporting is logged, never rethrown). Without waitUntil the tasks start when the body has been read to its end, or when the client cancels it; a platform waitUntil that throws is reported and the answer is sent as it was built. A request queues at most 32 tasks.

src/routes/api/track.tsts
import { after, apiRoute, json } from "@shadow-js/dusk/server";

export const GET = apiRoute({
  GET: (event) => {
    after(() => {
      console.info("viewed", event.url.pathname);
    });
    return json({ ok: true });
  },
});