Skip to content

Commit 2747cb4

Browse files
committed
Function export for utils.ts
1 parent 7ba1f16 commit 2747cb4

File tree

5 files changed

+21
-11
lines changed

5 files changed

+21
-11
lines changed

netlify/edge-functions/count.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
import headers from "./headers.ts";
2-
import { fetchFromSupabase } from "./utils.ts";
1+
import { headers } from "./headers.ts";
2+
import handler from "./utils.ts";
3+
4+
const { fetchFromSupabase } = handler();
35

46
export default async (request: Request): Promise<Response> => {
57
try {

netlify/edge-functions/latest.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
import headers from "./headers.ts";
2-
import { fetchFromSupabase } from "./utils.ts";
1+
import { headers } from "./headers.ts";
2+
import handler from "./utils.ts";
3+
4+
const { fetchFromSupabase } = handler();
35

46
export default async (request: Request): Promise<Response> => {
57
try {

netlify/edge-functions/redirect.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import { fetchFromSupabase } from "./utils.ts";
1+
import handler from "./utils.ts";
2+
3+
const { fetchFromSupabase } = handler();
24

35
export default async (request: Request): Promise<Response> => {
46
try {

netlify/edge-functions/shorten.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { multiParser } from "https://deno.land/x/multiparser@0.114.0/mod.ts";
2-
import headers from "./headers.ts";
3-
import { fetchFromSupabase, generateShortUrl } from "./utils.ts";
2+
import { headers } from "./headers.ts";
3+
import handler from "./utils.ts";
4+
5+
const { fetchFromSupabase, generateShortUrl } = handler();
46

57
export default async (request: Request): Promise<Response> => {
68
try {

netlify/edge-functions/utils.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ export function generateShortUrl(): string {
2020
return crypto.randomUUID().substring(0, 7);
2121
}
2222

23-
export default {
24-
fetchFromSupabase,
25-
generateShortUrl,
26-
};
23+
export default function handler() {
24+
return {
25+
fetchFromSupabase,
26+
generateShortUrl,
27+
};
28+
}

0 commit comments

Comments
 (0)