Initial commit: Korea Tourism Agency website with AdminJS
- Full-stack Node.js/Express application with PostgreSQL - Modern ES modules architecture - AdminJS admin panel with Sequelize ORM - Tourism routes, guides, articles, bookings management - Responsive Bootstrap 5 frontend - Docker containerization with docker-compose - Complete database schema with migrations - Authentication system for admin panel - Dynamic placeholder images for tour categories
This commit is contained in:
33
src/config/database.js
Normal file
33
src/config/database.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import pkg from 'pg';
|
||||
const { Pool } = pkg;
|
||||
import dotenv from 'dotenv';
|
||||
|
||||
dotenv.config();
|
||||
|
||||
const pool = new Pool({
|
||||
host: process.env.DB_HOST || 'localhost',
|
||||
port: process.env.DB_PORT || 5432,
|
||||
database: process.env.DB_NAME || 'korea_tourism',
|
||||
user: process.env.DB_USER || 'tourism_user',
|
||||
password: process.env.DB_PASSWORD || 'tourism_password',
|
||||
max: 20,
|
||||
idleTimeoutMillis: 30000,
|
||||
connectionTimeoutMillis: 2000,
|
||||
});
|
||||
|
||||
// Test database connection
|
||||
pool.on('connect', () => {
|
||||
console.log('💾 Connected to PostgreSQL database');
|
||||
});
|
||||
|
||||
pool.on('error', (err) => {
|
||||
console.error('🔴 Database connection error:', err);
|
||||
});
|
||||
|
||||
const db = {
|
||||
pool,
|
||||
query: (text, params) => pool.query(text, params)
|
||||
};
|
||||
|
||||
export default db;
|
||||
export { pool };
|
||||
Reference in New Issue
Block a user