Skip to content

Commit

Permalink
fix: error handling and env
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaszkowic committed Jun 20, 2024
1 parent 3a34560 commit 30ff28b
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions supabase/functions/gdk_stats/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { createClient } from "https://esm.sh/@supabase/supabase-js@2";
import { corsHeaders } from "../_shared/cors.ts";

const SUPABASE_URL = Deno.env.get("URL");
const SUPABASE_ANON_KEY = Deno.env.get("ANON_KEY");
const SUPABASE_SERVICE_ROLE_KEY = Deno.env.get("SERVICE_ROLE_KEY");
const PUMPS_URL =
"https://ieokxbqvqedpcyvwmrsb.supabase.co/storage/v1/object/public/data_assets/pumps.geojson";
const SUPABASE_URL = Deno.env.get("SUPABASE_URL");
const SUPABASE_SERVICE_ROLE_KEY = Deno.env.get("SUPABASE_SERVICE_ROLE_KEY");
const PUMPS_URL = Deno.env.get("PUMPS_URL");

interface TreeSpecies {
speciesName?: string;
Expand Down Expand Up @@ -80,7 +78,7 @@ const getPumpsCount = async (): Promise<number> => {
};

const getMonthlyWaterings = async (): Promise<Monthly[]> => {
const { data } = await supabaseServiceRoleClient
const { data, error } = await supabaseServiceRoleClient
.rpc("calculate_avg_waterings_per_month")
.select("*");
return data.map((month: any) => ({
Expand Down Expand Up @@ -128,6 +126,7 @@ const handler = async (request: Request): Promise<Response> => {
},
});
} catch (error) {
console.log(error);
return new Response(JSON.stringify({ error: error.message }), {
status: 500,
headers: {
Expand Down

0 comments on commit 30ff28b

Please sign in to comment.