add blogs, move pictures to local + much more

This commit is contained in:
Zoe
2022-11-30 23:09:32 -06:00
parent 3b775e1eba
commit 66aa241a43
37 changed files with 4277 additions and 206 deletions

View File

@@ -3,15 +3,30 @@
// This enables autocomplete, go to definition, etc.
import { serve } from "https://deno.land/std@0.131.0/http/server.ts"
import { createClient } from 'https://esm.sh/@supabase/supabase-js@2'
console.log("Hello from Functions!")
console.log("Hello from functions!")
const emailRegex = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
serve(async (req) => {
const { name } = await req.json()
const data = {
message: `Hello ${name}!`,
if (req.method === 'OPTIONS') {
return new Response('ok')
}
const supabase = createClient(Deno.env.get('SUPABASE_URL'), Deno.env.get('SUPABASE_ANON_KEY'))
const { email, name } = await req.json()
if (!name || !email || !emailRegex.test(email)) throw new Error(
'Please provide a valid email address or name'
)
const { data, error } = await supabase
.from('subscribers')
.upsert({ name: name, email: email })
.select()
if (error) throw new Error(error.message)
return new Response(
JSON.stringify(data),
{ headers: { "Content-Type": "application/json" } },