chore: commit all changes
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
import { drizzle } from 'drizzle-orm/node-postgres';
|
||||
import { Pool } from 'pg';
|
||||
import { authSchema } from './schema';
|
||||
import { schema } from './schema';
|
||||
|
||||
type AuthDrizzleDb = ReturnType<typeof createDb>;
|
||||
type AppDrizzleDb = ReturnType<typeof createDb>;
|
||||
|
||||
declare global {
|
||||
// eslint-disable-next-line no-var
|
||||
var __fiscalAuthPgPool: Pool | undefined;
|
||||
var __fiscalPgPool: Pool | undefined;
|
||||
// eslint-disable-next-line no-var
|
||||
var __fiscalAuthDrizzleDb: AuthDrizzleDb | undefined;
|
||||
var __fiscalDrizzleDb: AppDrizzleDb | undefined;
|
||||
}
|
||||
|
||||
function getConnectionString() {
|
||||
@@ -21,21 +21,21 @@ function getConnectionString() {
|
||||
}
|
||||
|
||||
export function getPool() {
|
||||
if (!globalThis.__fiscalAuthPgPool) {
|
||||
globalThis.__fiscalAuthPgPool = new Pool({
|
||||
if (!globalThis.__fiscalPgPool) {
|
||||
globalThis.__fiscalPgPool = new Pool({
|
||||
connectionString: getConnectionString()
|
||||
});
|
||||
}
|
||||
|
||||
return globalThis.__fiscalAuthPgPool;
|
||||
return globalThis.__fiscalPgPool;
|
||||
}
|
||||
|
||||
function createDb() {
|
||||
return drizzle(getPool(), { schema: authSchema });
|
||||
return drizzle(getPool(), { schema });
|
||||
}
|
||||
|
||||
export const db = globalThis.__fiscalAuthDrizzleDb ?? createDb();
|
||||
export const db = globalThis.__fiscalDrizzleDb ?? createDb();
|
||||
|
||||
if (!globalThis.__fiscalAuthDrizzleDb) {
|
||||
globalThis.__fiscalAuthDrizzleDb = db;
|
||||
if (!globalThis.__fiscalDrizzleDb) {
|
||||
globalThis.__fiscalDrizzleDb = db;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user