Files
comfyui-deploy/web/src/db/db.ts
T
2024-01-25 19:34:40 +08:00

31 lines
952 B
TypeScript

import { Pool, neonConfig } from "@neondatabase/serverless";
import { drizzle as neonDrizzle } from "drizzle-orm/neon-serverless";
import * as schema from "./schema";
const isDevContainer = process.env.REMOTE_CONTAINERS !== undefined;
// if we're running locally
if (process.env.VERCEL_ENV !== "production" && process.env.VERCEL_ENV !== "preview") {
// Set the WebSocket proxy to work with the local instance
if (isDevContainer) {
// Running inside a VS Code devcontainer
neonConfig.wsProxy = (host) => "host.docker.internal:5481/v1";
} else {
// Not running inside a VS Code devcontainer
neonConfig.wsProxy = (host) => `${host}:5481/v1`;
}
// Disable all authentication and encryption
neonConfig.useSecureWebSocket = false;
neonConfig.pipelineTLS = false;
neonConfig.pipelineConnect = false;
}
export const db = neonDrizzle(
new Pool({
connectionString: process.env.POSTGRES_URL,
}),
{
schema,
},
);