fix(docs): align edge function docs (#47148)

## TL;DR 
aligns the remaining Phase 2 Edge Functions docs snippets with
`@supabase/server`

## Whats Fixed? 
updated outdated imports and version references, and refreshed JSON
examples to use Response.json()
where it makes sense. left non-JSON responses as is where the
integration or format actually needs them
## Ref: 
- towards COM-269 


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Documentation**
* Updated numerous Edge Function guides and examples to use modern
`npm:`/`jsr:` import specifiers instead of legacy Deno URL imports.
* Standardized success and error responses to return JSON consistently
(using `Response.json()` and equivalent helpers) and added/clarified
appropriate HTTP status codes.
* Improved example error payload shapes in several guides for clearer,
structured failures.
* **Chores**
* Refreshed version ranges in documentation and examples across SDKs and
client libraries.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Vaibhav authored and GitHub committed 2026-06-22 16:06:12 -05:00
1 parent 171ca026b5
commit 549c1fb6ca
22 files changed
+153 -125

No files matched your search

@@ -1,5 +1,5 @@
import { drizzle } from 'drizzle-orm/postgres-js'
import postgres from 'postgres'
import { drizzle } from 'npm:drizzle-orm@^0/postgres-js'
import postgres from 'npm:postgres@^3'
import { countries } from '../_shared/schema.ts'
@@ -1,4 +1,4 @@
import { Pool } from 'https://deno.land/x/postgres@v0.17.0/mod.ts'
import { Pool } from 'jsr:@db/postgres@^0'
// Create a database pool with one connection.
const pool = new Pool(
@@ -24,16 +24,16 @@ export default {
const result = await connection.queryObject`SELECT * FROM animals`
const animals = result.rows // [{ id: 1, name: "Lion" }, ...]
// Encode the result as pretty printed JSON
const body = JSON.stringify(
animals,
(_key, value) => (typeof value === 'bigint' ? value.toString() : value),
2
const data = animals.map((animal) =>
Object.fromEntries(
Object.entries(animal).map(([key, value]) => [
key,
typeof value === 'bigint' ? value.toString() : value,
])
)
)
// Return the response with the correct content type header
return new Response(body, {
status: 200,
return Response.json(data, {
headers: {
'Content-Type': 'application/json; charset=utf-8',
},
@@ -44,7 +44,7 @@ export default {
}
} catch (err) {
console.error(err)
return new Response(String(err?.message ?? err), { status: 500 })
return Response.json({ error: String(err?.message ?? err) }, { status: 500 })
}
},
}
@@ -3,7 +3,7 @@
// This enables autocomplete, go to definition, etc.
import { withSupabase } from 'npm:@supabase/server@^1'
import type { SupabaseClient } from 'npm:@supabase/supabase-js@2'
import type { SupabaseClient } from 'npm:@supabase/supabase-js@^2'
interface Task {
name: string
+1 -1
View File
@@ -142,7 +142,7 @@ server.listen(9999)
### Using npm packages in Functions
```ts
import express from 'npm:express@4.18.2'
import express from 'npm:express@^5'
const app = express()