Skip to content

Commit b4619df

Browse files
committed
Updated Headers
1 parent 1e9f98e commit b4619df

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

netlify/edge-functions/count.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { headers } from "./headers.ts";
1+
import headers from "./headers.ts";
22
import { fetchFromSupabase } from "./utils.ts";
33

44
export default async (request: Request): Promise<Response> => {

netlify/edge-functions/headers.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ export const headers = {
55
"Access-Control-Max-Age": "86400",
66
"Content-Type": "application/json",
77
};
8+
9+
export default () => headers;

netlify/edge-functions/latest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { headers } from "./headers.ts";
1+
import headers from "./headers.ts";
22
import { fetchFromSupabase } from "./utils.ts";
33

44
export default async (request: Request): Promise<Response> => {

netlify/edge-functions/shorten.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { multiParser } from "https://deno.land/x/multiparser@0.114.0/mod.ts";
2-
import { headers } from "./headers.ts";
2+
import headers from "./headers.ts";
33
import { fetchFromSupabase, generateShortUrl } from "./utils.ts";
44

55
export default async (request: Request): Promise<Response> => {
66
try {
7-
const form = await multiParser(request);
8-
const url = form.fields.url;
7+
const formData = await multiParser(request);
8+
const url = formData.fields.url;
99

1010
if (!url) {
1111
return new Response(JSON.stringify({ error: "No URL provided" }), {

netlify/edge-functions/utils.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
const SUPABASE_URL = Deno.env.get("SUPABASE_URL");
22
const SUPABASE_KEY = Deno.env.get("SUPABASE_ANON_KEY");
3-
const SUPABASE_TABLE = "urls";
43

54
export async function fetchFromSupabase(
65
endpoint: string,
@@ -20,3 +19,8 @@ export async function fetchFromSupabase(
2019
export function generateShortUrl(): string {
2120
return crypto.randomUUID().substring(0, 7);
2221
}
22+
23+
export default {
24+
fetchFromSupabase,
25+
generateShortUrl,
26+
};

0 commit comments

Comments
 (0)