generated from xmartlabs/flutter-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: uppdercase edge function * refactor: requested changes * refactor: minor change
- Loading branch information
1 parent
cbeaa91
commit f51426a
Showing
8 changed files
with
80 additions
and
30 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
supabase-ws-flutter-backend/supabase/functions/uppercase_message/index.ts
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,36 @@ | ||
// Follow this setup guide to integrate the Deno language server with your editor: | ||
// https://deno.land/manual/getting_started/setup_your_environment | ||
// This enables autocomplete, go to definition, etc. | ||
|
||
import { serve } from "https://deno.land/[email protected]/http/server.ts" | ||
import { createClient } from "https://esm.sh/@supabase/[email protected]?target=deno"; | ||
|
||
const supabaseClient = createClient( | ||
Deno.env.get("SUPABASE_URL") ?? "", | ||
Deno.env.get("SUPABASE_SERVICE_ROLE_KEY") ?? "", | ||
{ | ||
global: { | ||
headers: { | ||
Authorization: "Bearer " + Deno.env.get("SUPABASE_SERVICE_ROLE_KEY"), | ||
}, | ||
}, | ||
}, | ||
); | ||
|
||
serve(async (req) => { | ||
const { id, message } = await req.json() | ||
|
||
const capitalizedMessage = message.toUpperCase() | ||
|
||
const { error } = await supabaseClient.from("messages").update({ body: capitalizedMessage }).eq("id", id) | ||
|
||
if (error != null) { | ||
return new Response(JSON.stringify({ "message": "Error updating message" }), { headers: { "Content-Type": "application/json" } },) | ||
} | ||
|
||
|
||
return new Response( | ||
JSON.stringify({ "message": "Success" }), | ||
{ headers: { "Content-Type": "application/json" } }, | ||
) | ||
}) |
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
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