The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Merge branch 'feat/launch-week-4-thursday' of github.com:supabase/supabase into feat/launch-week-4-thursday
Alaister Young9d14423d9efc
diff --cc www/components/CodeBlock/CodeBlock.tsxindex 760119d519f,f40c06c5bb1..4bfa5ab8821--- a/www/components/CodeBlock/CodeBlock.tsx+++ b/www/components/CodeBlock/CodeBlock.tsx@@@ -28,9 -28,13 +28,13 @@@ export interface CodeBlockProps* Supports individual lines: '14', multiple lines: '14,15', or a range of lines '14..19'*/highlightLines?: string+ /**+ * Shows an application toolbar at the top+ */+ showToolbar?: boolean}-function CodeBlock(props: Props) {+function CodeBlock(props: CodeBlockProps) {let lang = props.lang? props.lang: props.classNamediff --cc www/pages/edge-functions/edge-functions.tsxindex ee7cde7a575,f2f5eee7189..54ac4b3c3b3--- a/www/pages/edge-functions/edge-functions.tsx+++ b/www/pages/edge-functions/edge-functions.tsx@@@ -177,56 -164,43 +177,61 @@@ function Database()</div></div><div className="col-span-7 overflow-hidden">- <ScrollableCodeBlock lang="ts" highlightLines={currentSelection}>- <CodeBlock++ <ScrollableCodeBlock++ lang="ts"++ highlightLines={currentSelection}+ showToolbar+ hideCopy- style={{ maxHeight: '520px' }}- className=" translate-y-14"- >{`import Container from 'components/Container'-import Layout from '~/components/Layouts/Default'-import Hero from 'components/Hero'++ >+ {`import { serve } from "https://deno.land/[email protected]/http/server.ts";+import { stripe } from "../_utils/stripe.ts";-import Features from 'components/Features/index'-import BuiltExamples from 'components/BuiltWithSupabase/index'-// Import Swiper styles if swiper used on page-import 'swiper/swiper.min.css'+serve(async (req) => {+ try {+ // Get the authorization header from the request.+ // When you invoke the function via the client library it will automatically pass the authenticated user's JWT.+ const authHeader = req.headers.get("Authorization")!;-type Props = {}+ // Create a Supabase client with the Auth context of the logged in user.+ const supabaseClient = createClient(+ // Supabase API URL - env var exported by default.+ Deno.env.get("SUPABASE_URL") ?? "",+ // Supabase API ANON KEY - env var exported by default.+ Deno.env.get("SUPABASE_ANON_KEY") ?? "",+ // Create client with Auth context of the user that called the function.+ // This way your row-level-security (RLS) policies are applied.+ { headers: { Authorization: authHeader } }+ );-const Index = ({}: Props) => {- return (- <>- <Layout>- <Container>- <Hero />- <Features />- <TwitterSocialSection />- <BuiltExamples />- <MadeForDevelopers />- <AdminAccess />- <CaseStudies />- <CTABanner />- </Container>- </Layout>- </>- )-}+ supabaseClient.auth.setAuth(authHeader)-export default Index-`}</CodeBlock>+ // Check if the user already has a Stripe customer ID in the Database.+ const { data, error } = await supabaseClient+ .from<Customer>("customers")+ .select("*");+ console.log(data?.length, data, error);+ if (error) throw error;+ if (data?.length === 1) {+ // Exactly one customer found, return it.+ const customer = data[0].stripe_customer_id;+ console.log(\`Found customer id: \${customer}\`);+ return customer;+ }++ // Create a PaymentIntent so that the SDK can charge the logged in customer.+ const paymentIntent = await stripe.paymentIntents.create({+ amount: 1099,+ currency: "usd",+ customer: customer,+ });+++ return new Response(JSON.stringify(res), { status: 200 });+ } catch (error) {+ return new Response(JSON.stringify(error), { status: 400 });+ }+});`}+ </ScrollableCodeBlock></div></div></div>