mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 09:25:06 +03:00
chore: update tshirt function
This commit is contained in:
1 parent
0706fa8719
commit
6d2e549e71
2 files changed
+12
-5
No files matched your search
@@ -2,10 +2,10 @@
|
||||
|
||||
To celebrate the support of GET requests in Supabase Edge Functions we're giving away some limited edition Functions Shirts!
|
||||
|
||||
To win a Supabase Edge Functions T-Shirt, make a GET request to https://obuldanrptloktxcffvn.functions.supabase.co/get-tshirt-competition with your email address, your Twitter handle (optional), and the correct answer, e.g.
|
||||
To win a Supabase Edge Functions T-Shirt, make a GET request to https://obuldanrptloktxcffvn.functions.supabase.co/get-tshirt-competition with your email address, your Twitter handle (optional), your t-shirt size (S-2XL) and the correct answer, e.g.
|
||||
|
||||
```text
|
||||
https://obuldanrptloktxcffvn.functions.supabase.co/get-tshirt-competition?email=testr@test.de&twitter=thorwebdev&answer=20
|
||||
https://obuldanrptloktxcffvn.functions.supabase.co/get-tshirt-competition?email=testr@test.de&twitter=thorwebdev&size=2XL&answer=20
|
||||
```
|
||||
|
||||
You can read the functions source code to figure out the answer ;)
|
||||
|
||||
@@ -27,11 +27,17 @@ serve(async (req) => {
|
||||
const url = new URL(req.url)
|
||||
const email = url.searchParams.get('email')
|
||||
const twitter = url.searchParams.get('twitter')
|
||||
const size = url.searchParams.get('size')
|
||||
const answer = url.searchParams.get('answer')
|
||||
|
||||
if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email ?? '') || !answer)
|
||||
if (
|
||||
!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email ?? '') ||
|
||||
!answer ||
|
||||
!twitter ||
|
||||
!size
|
||||
)
|
||||
throw new Error(
|
||||
`You're missing either a valid 'email' and/or 'answer' param(s). HINT: https://github.com/supabase/supabase/blob/master/examples/edge-functions/supabase/functions/get-tshirt-competition/index.ts`
|
||||
`Please provide valid 'email', 'twitter', 'size', and 'answer' params. HINT: https://github.com/supabase/supabase/blob/master/examples/edge-functions/supabase/functions/get-tshirt-competition/index.ts`
|
||||
)
|
||||
|
||||
if (Number(answer) !== positionInAlphabet(email!))
|
||||
@@ -50,6 +56,7 @@ serve(async (req) => {
|
||||
{
|
||||
email,
|
||||
twitter,
|
||||
size,
|
||||
},
|
||||
{ onConflict: 'email' }
|
||||
)
|
||||
@@ -71,4 +78,4 @@ serve(async (req) => {
|
||||
})
|
||||
|
||||
// To invoke:
|
||||
// curl -i --location --request GET 'http://localhost:54321/functions/v1/get-tshirt-competition?email=testr@test.de&answer=20'
|
||||
// curl -i --location --request GET 'http://localhost:54321/functions/v1/get-tshirt-competition?email=testr@test.de&twitter=thorwebdev&size=2XL&answer=20'
|
||||
Reference in new issue
Block a user