import type { Env } from "./store-interface.js";
import type { ClickInput, Link } from "./types.js";
export interface ShortlinksRuntimeStore {
totalStats(): {
domains: number;
links: number;
clicks: number;
} | Promise<{
domains: number;
links: number;
clicks: number;
}>;
resolve(hostname: string, slug: string): Link | null | Promise;
recordClick(link: Link, input?: ClickInput): unknown | Promise;
}
export interface RecordClickErrorContext {
link: Link;
request: Request;
}
export interface ShortlinksHandlerOptions {
/** Inject the already-resolved hosted or local store. Required unless local mode is explicitly selected. */
store?: ShortlinksRuntimeStore;
/** Local database path. Never an opt-in by itself. */
dbPath?: string;
/** Environment used only to verify and resolve the explicit local-store opt-in. */
env?: Env;
/** Optional sink for the explicit-local notice. */
notice?: (line: string) => void;
/** Host fallback for synthetic/direct requests that have no Host header. */
defaultHost?: string;
/** Trust X-Forwarded-Host from a separately authenticated proxy. False by default. */
trustForwardedHost?: boolean;
/** Shared edge secret required before configured public routing hints are accepted. */
linkRouterSecret?: string;
linkRouterAuthHeader?: string;
publicHostHeader?: string;
publicProtoHeader?: string;
reservedPathPrefixes?: Iterable;
redirectStatus?: 301 | 302 | 307 | 308;
onRecordClickError?: (error: unknown, context: RecordClickErrorContext) => void | Promise;
}
export declare const LINK_ROUTER_AUTH_HEADER = "x-shortlinks-router-auth";
export declare function createShortlinksHandler(options?: ShortlinksHandlerOptions): (request: Request) => Response | Promise;
export declare function serveShortlinks(options?: ShortlinksHandlerOptions & {
host?: string;
port?: number;
}): Bun.Server;