From 2024855c8de0f4ee3eb81f32acfd729968bbf2e5 Mon Sep 17 00:00:00 2001 From: Chris Chinchilla Date: Thu, 14 May 2026 15:56:41 +0100 Subject: [PATCH] docs: Update old Deno usage (#45934) --- .../guides/ai/examples/huggingface-image-captioning.mdx | 4 ++-- apps/docs/content/guides/ai/hugging-face.mdx | 3 +-- .../content/guides/auth/oauth-server/token-security.mdx | 7 ++----- apps/docs/content/guides/functions/kysely-postgres.mdx | 8 ++++---- .../functions/slack-bot-mention/slack-bot-mention.md | 3 +-- 5 files changed, 10 insertions(+), 15 deletions(-) diff --git a/apps/docs/content/guides/ai/examples/huggingface-image-captioning.mdx b/apps/docs/content/guides/ai/examples/huggingface-image-captioning.mdx index 11f0672f9d6..b6b7b05ea47 100644 --- a/apps/docs/content/guides/ai/examples/huggingface-image-captioning.mdx +++ b/apps/docs/content/guides/ai/examples/huggingface-image-captioning.mdx @@ -39,9 +39,9 @@ supabase gen types typescript --project-id=your-project-ref --schema=storage,pub Find the complete code on [GitHub](https://github.com/supabase/supabase/tree/master/examples/edge-functions/supabase/functions/huggingface-image-captioning). ```ts -import { serve } from 'https://deno.land/std@0.168.0/http/server.ts' import { HfInference } from 'https://esm.sh/@huggingface/inference@2.3.2' import { createClient } from 'npm:@supabase/supabase-js@2' + import { Database } from './types.ts' console.log('Hello from `huggingface-image-captioning` function!') @@ -57,7 +57,7 @@ interface WebhookPayload { old_record: null | SoRecord } -serve(async (req) => { +Deno.serve(async (req) => { const payload: WebhookPayload = await req.json() const soRecord = payload.record const SUPABASE_SECRET_KEYS = JSON.parse(Deno.env.get('SUPABASE_SECRET_KEYS')!) diff --git a/apps/docs/content/guides/ai/hugging-face.mdx b/apps/docs/content/guides/ai/hugging-face.mdx index 424c16dc55c..082a73a1370 100644 --- a/apps/docs/content/guides/ai/hugging-face.mdx +++ b/apps/docs/content/guides/ai/hugging-face.mdx @@ -94,12 +94,11 @@ HUGGING_FACE_ACCESS_TOKEN= Let's modify the Edge Function to import Hugging Face's inference client and perform a `text-to-image` request: ```ts -import { serve } from 'https://deno.land/std@0.168.0/http/server.ts' import { HfInference } from 'https://esm.sh/@huggingface/inference@2.3.2' const hf = new HfInference(Deno.env.get('HUGGING_FACE_ACCESS_TOKEN')) -serve(async (req) => { +Deno.serve(async (req) => { const { prompt } = await req.json() const image = await hf.textToImage( diff --git a/apps/docs/content/guides/auth/oauth-server/token-security.mdx b/apps/docs/content/guides/auth/oauth-server/token-security.mdx index 069d6098c1f..b5da836eb94 100644 --- a/apps/docs/content/guides/auth/oauth-server/token-security.mdx +++ b/apps/docs/content/guides/auth/oauth-server/token-security.mdx @@ -182,9 +182,7 @@ Custom Access Token Hooks are triggered for **all** token issuance. Use `client_ A common use case is customizing the `audience` claim for different OAuth clients. This allows third-party services to validate that tokens were issued specifically for them: ```typescript -import { serve } from 'https://deno.land/std@0.168.0/http/server.ts' - -serve(async (req) => { +Deno.serve(async (req) => { const { user, claims, client_id } = await req.json() // Customize audience based on OAuth client @@ -230,10 +228,9 @@ The `audience` claim is especially important for: You can also add custom claims and metadata based on the OAuth client: ```typescript -import { serve } from 'https://deno.land/std@0.168.0/http/server.ts' import { createClient } from 'https://esm.sh/@supabase/supabase-js@2' -serve(async (req) => { +Deno.serve(async (req) => { const { user, claims, client_id } = await req.json() const supabase = createClient(Deno.env.get('SUPABASE_URL')!, Deno.env.get('SUPABASE_SECRET_KEY')!) diff --git a/apps/docs/content/guides/functions/kysely-postgres.mdx b/apps/docs/content/guides/functions/kysely-postgres.mdx index 22f4e09ecbf..a8930899f96 100644 --- a/apps/docs/content/guides/functions/kysely-postgres.mdx +++ b/apps/docs/content/guides/functions/kysely-postgres.mdx @@ -34,6 +34,7 @@ GET YOUR CERT FROM YOUR PROJECT DASHBOARD Create a `DenoPostgresDriver.ts` file to manage the connection to Postgres via [deno-postgres](https://deno-postgres.com/): ```ts DenoPostgresDriver.ts +import { Pool, PoolClient } from 'https://deno.land/x/postgres@v0.17.0/mod.ts' import { CompiledQuery, DatabaseConnection, @@ -44,7 +45,6 @@ import { } from 'https://esm.sh/kysely@0.23.4' import { freeze, isFunction } from 'https://esm.sh/kysely@0.23.4/dist/esm/util/object-utils.js' import { extendStackTrace } from 'https://esm.sh/kysely@0.23.4/dist/esm/util/stack-trace-utils.js' -import { Pool, PoolClient } from 'https://deno.land/x/postgres@v0.17.0/mod.ts' export interface PostgresDialectConfig { pool: Pool | (() => Promise) @@ -190,15 +190,15 @@ class PostgresConnection implements DatabaseConnection { Create an `index.ts` file to execute a query on incoming requests: ```ts index.ts -import { serve } from 'https://deno.land/std@0.175.0/http/server.ts' import { Pool } from 'https://deno.land/x/postgres@v0.17.0/mod.ts' import { - Kysely, Generated, + Kysely, PostgresAdapter, PostgresIntrospector, PostgresQueryCompiler, } from 'https://esm.sh/kysely@0.23.4' + import { PostgresDriver } from './DenoPostgresDriver.ts' console.log(`Function "kysely-postgres" up and running!`) @@ -245,7 +245,7 @@ const db = new Kysely({ }, }) -serve(async (_req) => { +Deno.serve(async (_req) => { try { // Run a query const animals = await db.selectFrom('animals').select(['id', 'animal', 'created_at']).execute() diff --git a/examples/edge-functions/supabase/functions/slack-bot-mention/slack-bot-mention.md b/examples/edge-functions/supabase/functions/slack-bot-mention/slack-bot-mention.md index c07b9d27509..c7426bd13f7 100644 --- a/examples/edge-functions/supabase/functions/slack-bot-mention/slack-bot-mention.md +++ b/examples/edge-functions/supabase/functions/slack-bot-mention/slack-bot-mention.md @@ -23,14 +23,13 @@ set SLACK_TOKEN= Here's the code of the Edge Function, you can change the response to handle the text received: ```ts index.ts -import { serve } from 'https://deno.land/std@0.197.0/http/server.ts' import { WebClient } from 'https://deno.land/x/slack_web_api@6.7.2/mod.js' const slackBotToken = Deno.env.get('SLACK_TOKEN') ?? '' const botClient = new WebClient(slackBotToken) console.log(`Slack URL verification function up and running!`) -serve(async (req) => { +Deno.serve(async (req) => { try { const reqBody = await req.json() console.log(JSON.stringify(reqBody, null, 2))