Skip to content

createFetchHandler

function createFetchHandler(options): CreateFetchHandlerResult;

Defined in: src/server/create-fetch-handler.ts:129

Build the panel fetch handler.

Parameter Type
options LinksPanelOptions

CreateFetchHandlerResult

import { createFetchHandler, createRedirectHandler } from "@xtandard/links";
import { createFileStorage } from "@xtandard/links/storage/file";
const panel = createFetchHandler({
storage: createFileStorage({ dir: "./data/links" }),
basePath: "/links",
defaultDomain: "go.acme.com",
});
const redirects = createRedirectHandler({ core: panel.core });
Bun.serve({
fetch: async (req) => (await redirects.handle(req)) ?? panel.fetch(req),
});