Skip to content

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

feat: added oak server example

Lakshan Perera1c1e440f3f1f
diff --git a/examples/edge-functions/supabase/functions/oak-server/README.md b/examples/edge-functions/supabase/functions/oak-server/README.md
new file mode 100644
index 00000000000..b1db6166231
--- /dev/null
+++ b/examples/edge-functions/supabase/functions/oak-server/README.md
@@ -0,0 +1,24 @@
+# Writing functions using Oak Server Middleware
+
+This example shows how you can write functions using Oak server middleware (https://oakserver.github.io/oak/)
+
+## Run locally
+
+```bash
+supabase functions serve oak-server
+```
+
+Use cURL or Postman to make a POST request to http://localhost:54321/functions/v1/oak-server.
+
+```
+ curl --location --request POST 'http://localhost:54321/functions/v1/oak-server' \
+--header 'Authorization: Bearer YOUR_TOKEN' \
+--header 'Content-Type: application/json' \
+--data-raw '{ "name": "John Doe" }'
+```
+
+## Deploy
+
+```bash
+supabase functions deploy oak-server
+```
diff --git a/examples/edge-functions/supabase/functions/oak-server/index.ts b/examples/edge-functions/supabase/functions/oak-server/index.ts
new file mode 100644
index 00000000000..c2891bd4e75
--- /dev/null
+++ b/examples/edge-functions/supabase/functions/oak-server/index.ts
@@ -0,0 +1,13 @@
+import { Application } from 'https://deno.land/x/oak/mod.ts'
+
+const app = new Application()
+
+app.use(async (ctx) => {
+ const result = ctx.request.body({ type: 'json', limit: 0 })
+ const body = await result.value
+ const name = body.name || 'you'
+
+ ctx.response.body = { msg: `Hey ${name}!` }
+})
+
+await app.listen({ port: 8000 })