|
1 | | -import supabaseAdmin, { isAdminAvailable } from '~/lib/supabase-admin' |
| 1 | +import supabaseAdmin from '~/lib/supabase-admin' |
2 | 2 |
|
3 | 3 | // [Alaister]: These functions are to be called server side only |
4 | 4 | // as they bypass RLS. They will not work client side. |
5 | 5 |
|
6 | 6 | export async function getAllProfiles() { |
7 | | - // During build time, if admin client isn't available, return empty array |
8 | | - if (!isAdminAvailable()) { |
9 | | - console.warn('SUPABASE_SERVICE_ROLE_KEY not available during build - skipping profile paths generation') |
10 | | - return [] |
11 | | - } |
12 | | - |
13 | | - try { |
14 | | - const [{ data: organizations }, { data: accounts }] = await Promise.all([ |
15 | | - supabaseAdmin |
16 | | - .from('organizations') |
17 | | - .select('handle') |
18 | | - .order('created_at', { ascending: false }) |
19 | | - .limit(500) |
20 | | - .returns<{ handle: string }[]>(), |
21 | | - supabaseAdmin |
22 | | - .from('accounts') |
23 | | - .select('handle') |
24 | | - .order('created_at', { ascending: false }) |
25 | | - .limit(500) |
26 | | - .returns<{ handle: string }[]>(), |
27 | | - ]) |
| 7 | + const [{ data: organizations }, { data: accounts }] = await Promise.all([ |
| 8 | + supabaseAdmin |
| 9 | + .from('organizations') |
| 10 | + .select('handle') |
| 11 | + .order('created_at', { ascending: false }) |
| 12 | + .limit(500) |
| 13 | + .returns<{ handle: string }[]>(), |
| 14 | + supabaseAdmin |
| 15 | + .from('accounts') |
| 16 | + .select('handle') |
| 17 | + .order('created_at', { ascending: false }) |
| 18 | + .limit(500) |
| 19 | + .returns<{ handle: string }[]>(), |
| 20 | + ]) |
28 | 21 |
|
29 | | - return [...(organizations ?? []), ...(accounts ?? [])] |
30 | | - } catch (error) { |
31 | | - console.error('Error fetching profiles for static paths:', error) |
32 | | - return [] |
33 | | - } |
| 22 | + return [...(organizations ?? []), ...(accounts ?? [])] |
34 | 23 | } |
35 | 24 |
|
36 | 25 | export async function getAllPackages() { |
37 | | - // During build time, if admin client isn't available, return empty array |
38 | | - if (!isAdminAvailable()) { |
39 | | - console.warn('SUPABASE_SERVICE_ROLE_KEY not available during build - skipping package paths generation') |
40 | | - return [] |
41 | | - } |
| 26 | + const { data } = await supabaseAdmin |
42 | 27 |
|
43 | | - try { |
44 | | - const { data } = await supabaseAdmin |
45 | | - .from('packages') |
46 | | - .select('handle,partial_name') |
47 | | - .order('created_at', { ascending: false }) |
48 | | - .limit(1000) |
49 | | - .returns<{ handle: string; partial_name: string }[]>() |
| 28 | + .from('packages') |
| 29 | + .select('handle,partial_name') |
| 30 | + .order('created_at', { ascending: false }) |
| 31 | + .limit(1000) |
| 32 | + .returns<{ handle: string; partial_name: string }[]>() |
50 | 33 |
|
51 | | - return data ?? [] |
52 | | - } catch (error) { |
53 | | - console.error('Error fetching packages for static paths:', error) |
54 | | - return [] |
55 | | - } |
| 34 | + return data ?? [] |
56 | 35 | } |
0 commit comments