const { createClient } = require("@supabase/supabase-js") const supabase = createClient(process.env.SUPABASE_URL, process.env.SUPABASE_KEY) async function uploadProfileImage(userId, file) { const path = `avatars/${userId}_${Date.now()}.jpg` const { data, error } = await supabase.storage .from("deal") .upload(path, file.data, { contentType: "image/jpeg", upsert: true, }) if (error) throw new Error(error.message) const { data: publicUrl } = supabase.storage.from("avatars").getPublicUrl(path) return publicUrl.publicUrl } module.exports = { uploadProfileImage }