mirror of
https://github.com/4ev-link/4ev.link.git
synced 2026-01-14 08:38:39 +00:00
Refactor: Return full link details for editing
This commit is contained in:
@@ -12,7 +12,16 @@ export async function onRequestPost({ request, env }) {
|
|||||||
if (Array.isArray(parsed)) slugs = parsed;
|
if (Array.isArray(parsed)) slugs = parsed;
|
||||||
} catch {}
|
} catch {}
|
||||||
|
|
||||||
return Response.json(slugs);
|
if (slugs.length === 0) return Response.json([]);
|
||||||
|
|
||||||
|
const destinations = await Promise.all(slugs.map(slug => env.KV_EV.get(slug)));
|
||||||
|
const links = slugs.map((slug, i) => ({
|
||||||
|
slug: slug,
|
||||||
|
destination_url: destinations[i] || "",
|
||||||
|
analytics: false,
|
||||||
|
}));
|
||||||
|
|
||||||
|
return Response.json(links.reverse());
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return new Response(e.message, { status: 500 });
|
return new Response(e.message, { status: 500 });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user