17 lines
405 B
TypeScript
17 lines
405 B
TypeScript
import { PrismaClient } from '@prisma/client';
|
|
import { logger } from '../utils/logger';
|
|
|
|
export const prisma = new PrismaClient({
|
|
log: ['warn', 'error'],
|
|
});
|
|
|
|
export const connectDB = async () => {
|
|
try {
|
|
await prisma.$connect();
|
|
logger.info('Connected to PostgreSQL successfully.');
|
|
} catch (error) {
|
|
logger.error('Failed to connect to PostgreSQL:', error);
|
|
process.exit(1);
|
|
}
|
|
};
|