-
Notifications
You must be signed in to change notification settings - Fork 0
backmerge #148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
backmerge #148
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,24 @@ | ||
| import { drizzle } from "drizzle-orm/node-postgres"; | ||
| import { Pool } from "pg"; | ||
| /// <reference types="node" /> | ||
| import { drizzle } from "drizzle-orm/postgres-js"; | ||
| import postgres, { type Sql } from "postgres"; | ||
| import * as schema from "./schema"; | ||
|
|
||
| let pool: Pool | null = null; | ||
| let client: Sql | null = null; | ||
|
|
||
| function getPool(): Pool { | ||
| if (!pool) { | ||
| function getClient(): Sql { | ||
| if (!client) { | ||
| const connectionString = process.env.DATABASE_URL; | ||
| if (!connectionString) { | ||
| throw new Error("DATABASE_URL environment variable is not set"); | ||
| } | ||
| pool = new Pool({ connectionString }); | ||
| // Supabase の Transaction pool mode は prepared statement をサポートしないため無効化 | ||
| client = postgres(connectionString, { prepare: false }); | ||
|
Comment on lines
+14
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 Info: prepare: false disables prepared statements globally Setting Was this helpful? React with 👍 or 👎 to provide feedback. |
||
| } | ||
| return pool; | ||
| return client; | ||
| } | ||
|
Comment on lines
+6
to
18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 Info: No connection cleanup / graceful shutdown handling The Was this helpful? React with 👍 or 👎 to provide feedback. |
||
|
|
||
| export function getDb() { | ||
| return drizzle(getPool(), { schema }); | ||
| return drizzle(getClient(), { schema }); | ||
| } | ||
|
Comment on lines
20
to
22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 Info: getDb() creates a new drizzle instance on every call Each call to Was this helpful? React with 👍 or 👎 to provide feedback. |
||
|
|
||
| export type DrizzleDb = ReturnType<typeof getDb>; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
/// <reference types="node" />directive is the only occurrence in the repo and is likely redundant given@types/nodeis already a devDependency andtsconfig.jsondoesn’t restricttypes. Keeping this can cause the generated.d.tsfor this module to include an implicit dependency on Node types for downstream consumers. Prefer removing the directive (or, if Node types truly need to be forced project-wide, configure it viatsconfig.jsoninstead).