Skip to content

Commit 57c3d01

Browse files
committed
Update latest.ts
1 parent 2747cb4 commit 57c3d01

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

netlify/edge-functions/latest.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { headers } from "./headers.ts";
22
import handler from "./utils.ts";
33

4+
const urlBase = Deno.env.get("URL_BASE") ? Deno.env.get("URL_BASE") : "";
45
const { fetchFromSupabase } = handler();
56

67
export default async (request: Request): Promise<Response> => {
@@ -11,7 +12,12 @@ export default async (request: Request): Promise<Response> => {
1112
`urls?order=created_at.desc&limit=${count}`,
1213
{ method: "GET" }
1314
);
14-
return new Response(JSON.stringify(data), { status: 200, headers });
15+
const modifiedData = data.map((item: any) => ({
16+
...item,
17+
short_url: `${urlBase}/${item.short_url}`,
18+
}));
19+
20+
return new Response(JSON.stringify(modifiedData), { status: 200, headers });
1521
} catch (err) {
1622
return new Response(
1723
JSON.stringify({ error: "Internal server error", details: err.message }),

0 commit comments

Comments
 (0)