"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.connectDB = exports.prisma = void 0;
require("dotenv/config");
const client_1 = require("@prisma/client");
const logger_1 = require("./logger");
exports.prisma = global.prismaGlobal ||
    new client_1.PrismaClient({
        log: process.env.PRISMA_QUERY_LOG === 'true'
            ? ['query', 'error', 'warn']
            : ['error', 'warn'],
    });
if (process.env.NODE_ENV !== 'production') {
    global.prismaGlobal = exports.prisma;
}
const connectDB = async () => {
    try {
        await exports.prisma.$connect();
        logger_1.logger.info('🐘 Database connected successfully via Prisma');
    }
    catch (error) {
        logger_1.logger.error(`❌ Database connection error: ${error.message}`);
    }
};
exports.connectDB = connectDB;
exports.default = exports.prisma;
//# sourceMappingURL=database.js.map