-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1ef0933
commit ee04753
Showing
6 changed files
with
114 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { ActionFunction, json } from '@remix-run/node' | ||
import { createClient } from '@supabase/supabase-js' | ||
|
||
export const action: ActionFunction = async ({ request }) => { | ||
const url = process.env.SUPABASE_URL | ||
const key = process.env.SUPABASE_ANON_KEY | ||
|
||
if (!url || !key) { | ||
return json({ error: 'Missing Supabase URL or key' }, 500) | ||
} | ||
|
||
const supabase = createClient(url, key, { | ||
db: { | ||
schema: 'public', | ||
}, | ||
}) | ||
|
||
switch (request.method) { | ||
case 'POST': { | ||
try { | ||
const body = await request.formData() | ||
|
||
const res = await supabase.from('feedback').insert({ | ||
feedback: body.get('feedback'), | ||
page_title: body.get('pageTitle'), | ||
upvoted: body.get('variant') === 'upvote', | ||
}) | ||
|
||
return json({ success: true }, 200) | ||
} catch (err) { | ||
return json({ success: false, error: err.message }, 405) | ||
} | ||
} | ||
default: | ||
return json({ success: false, error: 'Method not allowed' }, 405) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters