Skip to content

Commit 4794504

Browse files
committed
feat: setup supabase
0 parents  commit 4794504

File tree

5 files changed

+118
-0
lines changed

5 files changed

+118
-0
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# openai-edge-functions
2+
3+
ref: https://youtu.be/29p8kIqyU_Y
4+
5+
## Tech Stack
6+
7+
- Supabase
8+
- Deno

supabase/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Supabase
2+
.branches
3+
.temp

supabase/config.toml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# A string used to distinguish different Supabase projects on the same host. Defaults to the working
2+
# directory name when running `supabase init`.
3+
project_id = "openai-edge-functions"
4+
5+
[api]
6+
# Port to use for the API URL.
7+
port = 54321
8+
# Schemas to expose in your API. Tables, views and stored procedures in this schema will get API
9+
# endpoints. public and storage are always included.
10+
schemas = ["public", "storage", "graphql_public"]
11+
# Extra schemas to add to the search_path of every request. public is always included.
12+
extra_search_path = ["public", "extensions"]
13+
# The maximum number of rows returns from a view, table, or stored procedure. Limits payload size
14+
# for accidental or malicious requests.
15+
max_rows = 1000
16+
17+
[db]
18+
# Port to use for the local database URL.
19+
port = 54322
20+
# The database major version to use. This has to be the same as your remote database's. Run `SHOW
21+
# server_version;` on the remote database to check.
22+
major_version = 15
23+
24+
[studio]
25+
# Port to use for Supabase Studio.
26+
port = 54323
27+
28+
# Email testing server. Emails sent with the local dev setup are not actually sent - rather, they
29+
# are monitored, and you can view the emails that would have been sent from the web interface.
30+
[inbucket]
31+
# Port to use for the email testing server web interface.
32+
port = 54324
33+
smtp_port = 54325
34+
pop3_port = 54326
35+
36+
[storage]
37+
# The maximum file size allowed (e.g. "5MB", "500KB").
38+
file_size_limit = "50MiB"
39+
40+
[auth]
41+
# The base URL of your website. Used as an allow-list for redirects and for constructing URLs used
42+
# in emails.
43+
site_url = "http://localhost:3000"
44+
# A list of *exact* URLs that auth providers are permitted to redirect to post authentication.
45+
additional_redirect_urls = ["https://localhost:3000"]
46+
# How long tokens are valid for, in seconds. Defaults to 3600 (1 hour), maximum 604,800 seconds (one
47+
# week).
48+
jwt_expiry = 3600
49+
# Allow/disallow new user signups to your project.
50+
enable_signup = true
51+
52+
[auth.email]
53+
# Allow/disallow new user signups via email to your project.
54+
enable_signup = true
55+
# If enabled, a user will be required to confirm any email change on both the old, and new email
56+
# addresses. If disabled, only the new email is required to confirm.
57+
double_confirm_changes = true
58+
# If enabled, users need to confirm their email address before signing in.
59+
enable_confirmations = false
60+
61+
# Use an external OAuth provider. The full list of providers are: `apple`, `azure`, `bitbucket`,
62+
# `discord`, `facebook`, `github`, `gitlab`, `google`, `keycloak`, `linkedin`, `notion`, `twitch`,
63+
# `twitter`, `slack`, `spotify`, `workos`, `zoom`.
64+
[auth.external.apple]
65+
enabled = false
66+
client_id = ""
67+
secret = ""
68+
# Overrides the default auth redirectUrl.
69+
redirect_uri = ""
70+
# Overrides the default auth provider URL. Used to support self-hosted gitlab, single-tenant Azure,
71+
# or any other third-party OIDC providers.
72+
url = ""
73+
74+
[analytics]
75+
enabled = false
76+
port = 54327
77+
vector_port = 54328
78+
# Setup BigQuery project to enable log viewer on local development stack.
79+
# See: https://logflare.app/guides/bigquery-setup
80+
gcp_project_id = ""
81+
gcp_project_number = ""
82+
gcp_jwt_path = "supabase/gcloud.json"

supabase/functions/openai/index.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Follow this setup guide to integrate the Deno language server with your editor:
2+
// https://deno.land/manual/getting_started/setup_your_environment
3+
// This enables autocomplete, go to definition, etc.
4+
5+
import { serve } from "https://deno.land/std@0.168.0/http/server.ts"
6+
7+
console.log("Hello from Functions!")
8+
9+
serve(async (req) => {
10+
const { name } = await req.json()
11+
const data = {
12+
message: `Hello ${name}!`,
13+
}
14+
15+
return new Response(
16+
JSON.stringify(data),
17+
{ headers: { "Content-Type": "application/json" } },
18+
)
19+
})
20+
21+
// To invoke:
22+
// curl -i --location --request POST 'http://localhost:54321/functions/v1/' \
23+
// --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0' \
24+
// --header 'Content-Type: application/json' \
25+
// --data '{"name":"Functions"}'

supabase/seed.sql

Whitespace-only changes.

0 commit comments

Comments
 (0)