mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 17:35:10 +03:00
chore: update postgres on the edge.
This commit is contained in:
1 parent
89827c2084
commit
7bab95fced
3 files changed
+16
-9
No files matched your search
@@ -11,7 +11,8 @@ IPINFO_TOKEN="your https://ipinfo.io token"
|
||||
OPENAI_API_KEY="<YOUR API KEY HERE>"
|
||||
|
||||
# postgres-on-the-edge
|
||||
DATABASE_URL=
|
||||
DB_HOSTNAME=
|
||||
DB_PASSWORD=
|
||||
|
||||
# puppeteer
|
||||
PUPPETEER_BROWSERLESS_IO_TOKEN=
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
"stripe": "https://esm.sh/stripe@11.1.0?target=deno",
|
||||
"sift": "https://deno.land/x/sift@0.6.0/mod.ts",
|
||||
"@supabase/supabase-js": "https://esm.sh/@supabase/supabase-js@2.7.1",
|
||||
"postgres": "https://deno.land/x/postgres@v0.14.2/mod.ts",
|
||||
"postgres": "https://deno.land/x/postgres@v0.17.0/mod.ts",
|
||||
"puppeteer": "https://deno.land/x/puppeteer@16.2.0/mod.ts",
|
||||
"React": "https://esm.sh/react@18.2.0?deno-std=0.177.0",
|
||||
"upstash_redis": "https://deno.land/x/upstash_redis@v1.19.3/mod.ts",
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
import * as postgres from 'postgres'
|
||||
import { Pool } from 'postgres'
|
||||
import { serve } from 'std/server'
|
||||
|
||||
// Get the connection string from the environment variable "DATABASE_URL"
|
||||
const databaseUrl = Deno.env.get('DATABASE_URL')!
|
||||
|
||||
// Create a database pool with three connections that are lazily established
|
||||
const pool = new postgres.Pool(databaseUrl, 3, true)
|
||||
// Create a database pool with one connection.
|
||||
const pool = new Pool(
|
||||
{
|
||||
tls: { enabled: false },
|
||||
database: 'postgres',
|
||||
hostname: Deno.env.get('DB_HOSTNAME'),
|
||||
user: 'postgres',
|
||||
port: 5432,
|
||||
password: Deno.env.get('DB_PASSWORD'),
|
||||
},
|
||||
1
|
||||
)
|
||||
|
||||
serve(async (_req) => {
|
||||
try {
|
||||
@@ -16,7 +23,6 @@ serve(async (_req) => {
|
||||
// Run a query
|
||||
const result = await connection.queryObject`SELECT * FROM animals`
|
||||
const animals = result.rows // [{ id: 1, name: "Lion" }, ...]
|
||||
console.log(animals)
|
||||
|
||||
// Encode the result as pretty printed JSON
|
||||
const body = JSON.stringify(
|
||||
|
||||
Reference in new issue
Block a user