globalThis.process ??= {}; globalThis.process.env ??= {};
import { g as generateShortLink } from '../../chunks/shortlink_FrzJzDij.mjs';
export { r as renderers } from '../../chunks/_@astro-renderers_DpxbEuk7.mjs';

const POST = async ({ request }) => {
  try {
    const { url } = await request.json();
    if (!url) {
      return new Response(JSON.stringify({ error: "URL is required" }), {
        status: 400,
        headers: { "Content-Type": "application/json" }
      });
    }
    const shortLink = await generateShortLink(url);
    return new Response(JSON.stringify({ shortLink }), {
      status: 200,
      headers: { "Content-Type": "application/json" }
    });
  } catch (error) {
    console.error("Error generating short link:", error);
    return new Response(JSON.stringify({ error: "Failed to generate short link" }), {
      status: 500,
      headers: { "Content-Type": "application/json" }
    });
  }
};

const _page = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
  __proto__: null,
  POST
}, Symbol.toStringTag, { value: 'Module' }));

const page = () => _page;

export { page };
