제어관리 외부커넥션 설정기능
This commit is contained in:
@@ -1,15 +1,20 @@
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
import config from "./environment";
|
||||
|
||||
// Prisma 클라이언트 인스턴스 생성
|
||||
const prisma = new PrismaClient({
|
||||
datasources: {
|
||||
db: {
|
||||
url: config.databaseUrl,
|
||||
// Prisma 클라이언트 생성 함수
|
||||
function createPrismaClient() {
|
||||
return new PrismaClient({
|
||||
datasources: {
|
||||
db: {
|
||||
url: config.databaseUrl,
|
||||
},
|
||||
},
|
||||
},
|
||||
log: config.debug ? ["query", "info", "warn", "error"] : ["error"],
|
||||
});
|
||||
log: config.debug ? ["query", "info", "warn", "error"] : ["error"],
|
||||
});
|
||||
}
|
||||
|
||||
// 단일 인스턴스 생성
|
||||
const prisma = createPrismaClient();
|
||||
|
||||
// 데이터베이스 연결 테스트
|
||||
async function testConnection() {
|
||||
@@ -41,4 +46,5 @@ if (config.nodeEnv === "development") {
|
||||
testConnection();
|
||||
}
|
||||
|
||||
export default prisma;
|
||||
// 기본 내보내기
|
||||
export = prisma;
|
||||
|
||||
@@ -80,7 +80,7 @@ const getCorsOrigin = (): string[] | boolean => {
|
||||
|
||||
const config: Config = {
|
||||
// 서버 설정
|
||||
port: parseInt(process.env.PORT || "3000", 10),
|
||||
port: parseInt(process.env.PORT || "8080", 10),
|
||||
host: process.env.HOST || "0.0.0.0",
|
||||
nodeEnv: process.env.NODE_ENV || "development",
|
||||
|
||||
|
||||
Reference in New Issue
Block a user