serverless-friendly postgres connection

This commit is contained in:
Avraham Sakal
2025-09-14 22:25:13 -04:00
parent c48c069b10
commit c98342e886
3 changed files with 50 additions and 8 deletions
+14 -8
View File
@@ -1,5 +1,7 @@
import { Pool } from "pg";
import { Kysely, PostgresDialect } from "kysely";
// import { Pool } from "pg";
import { neon } from "@neondatabase/serverless";
import { Kysely /*PostgresDialect*/ } from "kysely";
import { NeonDialect } from "kysely-neon";
import type Database from "./generated/Database";
import type {
ConversationEntity,
@@ -10,13 +12,17 @@ import type {
import type { CommittedMessage } from "../types";
import { env } from "../server/env.js";
export const pool = new Pool({
connectionString: env.POSTGRES_CONNECTION_STRING as string,
// channelBinding: require ?
});
// export const pool = new Pool({
// connectionString: env.POSTGRES_CONNECTION_STRING as string,
// // channelBinding: require ?
// });
const dialect = new PostgresDialect({
pool,
// const dialect = new PostgresDialect({
// pool,
// });
const dialect = new NeonDialect({
neon: neon(env.POSTGRES_CONNECTION_STRING as string),
});
// Database interface is passed to Kysely's constructor, and from now on, Kysely