Files
sori.studio/server/repositories/postgres-client.js

26 lines
456 B
JavaScript

import postgres from 'postgres'
let client = null
/**
* PostgreSQL 클라이언트 조회
* @returns {ReturnType<typeof postgres> | null} PostgreSQL 클라이언트
*/
export const getPostgresClient = () => {
const config = useRuntimeConfig()
if (!config.databaseUrl) {
return null
}
if (!client) {
client = postgres(config.databaseUrl, {
max: 5,
idle_timeout: 20,
connect_timeout: 10
})
}
return client
}