import handler from "@tanstack/react-start/server-entry";
import { paraglideMiddleware } from "./paraglide/server.js";

export default {
	async fetch(req: Request): Promise<Response> {
		// paraglide reads the URL prefix / cookie / Accept-Language and binds the
		// detected locale into AsyncLocalStorage for the duration of the request,
		// so any `getLocale()` calls during SSR see the right value.
		return paraglideMiddleware(req, () => handler.fetch(req));
	},
};
