PostgreSQL 데이터 계층 추가

This commit is contained in:
2026-04-29 15:22:54 +09:00
parent cbf5ed6c8c
commit 5ee6fcd54b
20 changed files with 429 additions and 34 deletions

View File

@@ -0,0 +1,25 @@
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
}