Docker 런타임 환경 변수 우선 적용
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import postgres from 'postgres'
|
||||
import { getRuntimeEnvValue } from '../utils/runtime-env'
|
||||
|
||||
let client = null
|
||||
|
||||
@@ -13,9 +14,9 @@ const isProductionRuntime = () => process.env.NODE_ENV === 'production'
|
||||
* @returns {ReturnType<typeof postgres> | null} PostgreSQL 클라이언트
|
||||
*/
|
||||
export const getPostgresClient = () => {
|
||||
const config = useRuntimeConfig()
|
||||
const databaseUrl = getRuntimeEnvValue('DATABASE_URL', 'databaseUrl').trim()
|
||||
|
||||
if (!config.databaseUrl) {
|
||||
if (!databaseUrl) {
|
||||
if (isProductionRuntime()) {
|
||||
throw new Error('DATABASE_URL_REQUIRED')
|
||||
}
|
||||
@@ -24,7 +25,7 @@ export const getPostgresClient = () => {
|
||||
}
|
||||
|
||||
if (!client) {
|
||||
client = postgres(config.databaseUrl, {
|
||||
client = postgres(databaseUrl, {
|
||||
max: 5,
|
||||
idle_timeout: 20,
|
||||
connect_timeout: 10
|
||||
|
||||
Reference in New Issue
Block a user