Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

feat: improve test client.

thorwebdevfd8751f32a00
diff --git a/examples/edge-functions/README.md b/examples/edge-functions/README.md
index 99028a5ec39..e0db8539038 100644
--- a/examples/edge-functions/README.md
+++ b/examples/edge-functions/README.md
@@ -15,7 +15,19 @@ The function examples are located in [`./supabase/functions`](./supabase/functio
- Run `supabase start` (make sure your Docker daemon is running.)
- Run `supabase functions serve your-function-name`
-- Run the CURL command in the example function, or use the [invoke method](https://supabase.com/docs/reference/javascript/invoke) on the Supabase client.
+- Run the CURL command in the example function, or use the [invoke method](https://supabase.com/docs/reference/javascript/invoke) on the Supabase client or use the test client [app](./app/).
+
+## Test
+
+This example includes a create-react-app in the [`./app/`](./app/) directory which you can use as a sort of postman to make test requests both locally and to your deployed functions.
+
+### Test locally
+
+- `cd app`
+- `npm install`
+- `npm start`
+
+Note: when testing locally, the select dropdown doesn't have any effect, and invoke simply calls whatever function is currently served by the CLI.
## Deploy
@@ -34,6 +46,16 @@ The function examples are located in [`./supabase/functions`](./supabase/functio
- Within your project root run `supabase functions deploy payment-sheet`
- In youre [`./app/.env`](./app/.env) file remove the `SUPA_FUNCTION_LOCALHOST` variable and restart your Expo app.
+### Test deployed functions
+
+This example includes a create-react-app in the [`./app/`](./app/) directory which you can use as a sort of postman to make test requests both locally and to your deployed functions.
+
+- `cd app`
+- `cp .env.example .env`
+- Fill in your env vars from https://app.supabase.io/project/_/settings/api
+- `npm install`
+- `npm start`
+
## 👁⚡️👁
\o/ That's it, you can now invoke your Supabase Function via the [`supabase-js`](https://supabase.com/docs/reference/javascript/invoke) and [`supabase-dart`](https://supabase.com/docs/reference/dart/invoke) client libraries. (More client libraries coming soon. Check the [supabase-community](https://github.com/supabase-community#client-libraries) org for details).
diff --git a/examples/edge-functions/app/.env.example b/examples/edge-functions/app/.env.example
new file mode 100644
index 00000000000..ee677d2bfde
--- /dev/null
+++ b/examples/edge-functions/app/.env.example
@@ -0,0 +1,3 @@
+# Get these from your Dashboard: https://app.supabase.io/project/_/settings/api
+REACT_APP_SUPABASE_URL=
+REACT_APP_SUPABASE_ANON_KEY=
\ No newline at end of file
diff --git a/examples/edge-functions/app/src/App.js b/examples/edge-functions/app/src/App.js
index b0bf416bdd6..9ae917ee3dd 100644
--- a/examples/edge-functions/app/src/App.js
+++ b/examples/edge-functions/app/src/App.js
@@ -6,13 +6,10 @@ import { createClient } from '@supabase/supabase-js'
import { functionsList } from './functionsList'
const { Title, Text, Link } = Typography
-// const supabase = createClient(
-// 'http://localhost:54321',
-// 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24ifQ.625_WdcF3KHqz5amU0x2X5WWHP-OEs_4qj0ssLNHzTs'
-// )
const supabase = createClient(
- 'https://gvkuljvaukfrwmrythfi.supabase.co',
- 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Imd2a3VsanZhdWtmcndtcnl0aGZpIiwicm9sZSI6ImFub24iLCJpYXQiOjE2NDg1NTA4MjQsImV4cCI6MTk2NDEyNjgyNH0.SJpObtyvXNXiVXFBtNED8K7dry5pnaHN7tswyYGQU00'
+ process.env.REACT_APP_SUPABASE_URL ?? 'http://localhost:54321',
+ process.env.REACT_APP_SUPABASE_ANON_KEY ??
+ 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24ifQ.625_WdcF3KHqz5amU0x2X5WWHP-OEs_4qj0ssLNHzTs'
)
const sampleObject = { name: 'world' }
@@ -43,6 +40,10 @@ function App() {
</Select.Option>
))}
</Select>
+ <Text>
+ Note: when using locally, this selection doesn't have any effect and the function that's
+ currently being served via the CLI is called instead.
+ </Text>
<Title level={4}>Body</Title>
<JSONInput
onChange={({ jsObject }) => setRequestJson(jsObject)}
diff --git a/examples/edge-functions/app/src/functionsList.js b/examples/edge-functions/app/src/functionsList.js
index 33a40055317..aad5982b277 100644
--- a/examples/edge-functions/app/src/functionsList.js
+++ b/examples/edge-functions/app/src/functionsList.js
@@ -1 +1,5 @@
-export const functionsList = ['browser-with-cors', 'select-from-table-with-auth-rls']
+export const functionsList = [
+ 'local: Whatever function is currently served by the CLI',
+ 'browser-with-cors',
+ 'select-from-table-with-auth-rls',
+]