Initial commit: CMS backend for Old Vine Hotel

- Complete Express.js API server
- MongoDB integration with Mongoose
- Admin authentication and authorization
- Room management (CRUD operations)
- Booking management system
- Guest management
- Payment processing (Stripe integration)
- Content management (pages, blog, gallery)
- Media upload and management
- Integration services (Booking.com, Expedia, Opera PMS, Trip.com)
- Email notifications
- Comprehensive logging and error handling
This commit is contained in:
Talal Sharabi
2026-01-06 12:21:56 +04:00
commit a3308a26e2
48 changed files with 15294 additions and 0 deletions

68
scripts/seedAdmin.js Normal file
View File

@@ -0,0 +1,68 @@
const mongoose = require('mongoose');
const Admin = require('../models/Admin');
require('dotenv').config();
const seedAdmin = async () => {
try {
// Connect to MongoDB
await mongoose.connect(process.env.MONGODB_URI || 'mongodb://localhost:27017/oldvinehotel', {
useNewUrlParser: true,
useUnifiedTopology: true,
});
console.log('Connected to MongoDB');
// Check if super admin already exists
const existingAdmin = await Admin.findOne({ isSuperAdmin: true });
if (existingAdmin) {
console.log('Super admin already exists:');
console.log('Username:', existingAdmin.username);
console.log('Email:', existingAdmin.email);
await mongoose.connection.close();
return;
}
// Create default super admin
const defaultAdmin = new Admin({
username: 'admin',
email: 'admin@oldvinehotel.com',
password: 'Admin@123456', // Change this in production!
firstName: 'Admin',
lastName: 'User',
role: 'super-admin',
isSuperAdmin: true,
permissions: [
'manage_content',
'manage_rooms',
'manage_bookings',
'manage_users',
'manage_blog',
'manage_gallery',
'manage_settings',
'view_analytics',
'manage_admins'
]
});
await defaultAdmin.save();
console.log('\n✅ Super admin created successfully!');
console.log('\n📝 Login Credentials:');
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
console.log('Username: admin');
console.log('Email: admin@oldvinehotel.com');
console.log('Password: Admin@123456');
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
console.log('\n⚠ Please change the password after first login!');
console.log('\n🌐 Admin Panel: http://localhost:3060/admin/login\n');
await mongoose.connection.close();
} catch (error) {
console.error('Error seeding admin:', error);
process.exit(1);
}
};
seedAdmin();

305
scripts/seedContent.js Normal file
View File

@@ -0,0 +1,305 @@
const mongoose = require('mongoose');
const Content = require('../models/Content');
const Room = require('../models/Room');
const SiteSettings = require('../models/SiteSettings');
require('dotenv').config();
const seedContent = async () => {
try {
// Connect to MongoDB
await mongoose.connect(process.env.MONGODB_URI || 'mongodb://localhost:27017/oldvinehotel', {
useNewUrlParser: true,
useUnifiedTopology: true,
});
console.log('Connected to MongoDB');
// ==================== HOMEPAGE CONTENT ====================
const homePageExists = await Content.findOne({ page: 'home' });
if (!homePageExists) {
await Content.create({
page: 'home',
hero: {
title: 'Welcome to Old Vine Hotel',
subtitle: 'Experience Luxury in the Heart of Old Damascus',
description: 'Discover timeless elegance and authentic Syrian hospitality in our beautifully restored historic hotel.',
backgroundImage: '/images/hero.jpg',
ctaText: 'Explore Rooms',
ctaLink: '/rooms'
},
sections: [
{
sectionId: 'welcome',
title: 'Your Home Away From Home',
subtitle: 'Experience Damascus Like Never Before',
content: 'Nestled in the historic heart of Old Damascus, Old Vine Hotel offers an unforgettable blend of traditional Syrian architecture and modern luxury. Each room tells a story, each corner whispers history, and every moment creates lasting memories.',
order: 1,
isActive: true,
layout: 'full-width'
},
{
sectionId: 'features',
title: 'Exceptional Amenities',
subtitle: 'Everything You Need for a Perfect Stay',
content: 'From luxurious accommodations to world-class dining, every detail has been carefully crafted to ensure your comfort.',
order: 2,
isActive: true,
layout: 'full-width',
items: [
{ icon: 'wifi', title: 'Free Wi-Fi', description: 'High-speed internet throughout the hotel' },
{ icon: 'restaurant', title: 'Fine Dining', description: 'Authentic Syrian and international cuisine' },
{ icon: 'spa', title: 'Spa & Wellness', description: 'Relax and rejuvenate in our spa' },
{ icon: 'concierge', title: '24/7 Concierge', description: 'Personalized service anytime' }
]
}
],
seo: {
title: 'Old Vine Hotel - Luxury Hotel in Old Damascus',
description: 'Experience timeless elegance and authentic Syrian hospitality at Old Vine Hotel, a beautifully restored historic hotel in the heart of Old Damascus.',
keywords: ['damascus hotel', 'old damascus', 'luxury hotel syria', 'boutique hotel damascus'],
ogImage: '/images/hero.jpg'
},
isPublished: true,
publishedAt: new Date()
});
console.log('✅ Created homepage content');
} else {
console.log(' Homepage content already exists');
}
// ==================== ABOUT PAGE CONTENT ====================
const aboutPageExists = await Content.findOne({ page: 'about' });
if (!aboutPageExists) {
await Content.create({
page: 'about',
hero: {
title: 'Our Story',
subtitle: 'A Legacy of Hospitality Since Heritage',
description: 'Discover the rich history and timeless charm of Old Vine Hotel',
backgroundImage: '/images/about-hero.jpg'
},
sections: [
{
sectionId: 'heritage',
title: 'Our Heritage',
content: 'Old Vine Hotel stands as a testament to the timeless beauty of Old Damascus. Built within the ancient walls of the historic city, our hotel preserves the architectural grandeur of traditional Damascene houses while offering contemporary comfort and luxury.\n\nEvery stone in our building has witnessed centuries of history, and we are honored to be custodians of this heritage. Our restoration project has carefully maintained the original character of the structure, from the intricate geometric patterns to the central courtyard that has welcomed guests for generations.',
image: '/images/about.jpg',
order: 1,
isActive: true,
layout: 'right-image'
},
{
sectionId: 'mission',
title: 'Our Mission',
content: 'To provide an authentic Damascus experience that honors our cultural heritage while delivering world-class hospitality. We believe in creating meaningful connections between our guests and the rich tapestry of Syrian culture, history, and tradition.',
order: 2,
isActive: true,
layout: 'left-image'
},
{
sectionId: 'vision',
title: 'Our Vision',
content: 'To be the premier destination for travelers seeking an authentic cultural experience in Damascus. We strive to preserve and share the beauty of Old Damascus while setting new standards in hospitality and guest satisfaction.',
order: 3,
isActive: true,
layout: 'full-width'
},
{
sectionId: 'values',
title: 'Our Values',
content: 'We are guided by principles of excellence, authenticity, and respect for our heritage.',
order: 4,
isActive: true,
layout: 'full-width',
items: [
{ title: 'Authenticity', description: 'Preserving and celebrating Syrian culture and traditions' },
{ title: 'Excellence', description: 'Delivering world-class service and hospitality' },
{ title: 'Heritage', description: 'Honoring the history and architecture of Old Damascus' },
{ title: 'Innovation', description: 'Blending tradition with modern comfort and technology' }
]
}
],
seo: {
title: 'About Old Vine Hotel - Our Story and Heritage',
description: 'Learn about Old Vine Hotel\'s rich history, mission, and commitment to preserving the cultural heritage of Old Damascus while providing exceptional hospitality.',
keywords: ['damascus heritage', 'historic hotel damascus', 'old damascus architecture'],
ogImage: '/images/about-hero.jpg'
},
isPublished: true,
publishedAt: new Date()
});
console.log('✅ Created about page content');
} else {
console.log(' About page content already exists');
}
// ==================== ROOMS ====================
// NOTE: Rooms need to match the actual Room schema which has specific requirements
const deluxeExists = await Room.findOne({ roomNumber: '101' });
if (!deluxeExists) {
await Room.create({
name: 'Deluxe Room',
type: 'Deluxe',
slug: 'deluxe-room',
description: 'Experience comfort and elegance in our spacious Deluxe Room, featuring traditional Damascene decor with modern amenities. Perfect for couples or solo travelers seeking a blend of authentic charm and contemporary comfort.',
shortDescription: 'Elegant comfort with traditional charm',
roomNumber: '101',
floor: 1,
size: 35,
maxOccupancy: 2,
bedType: 'King',
bedCount: 1,
basePrice: 150,
amenities: ['WiFi', 'TV', 'AC', 'Minibar', 'Safe', 'City View', 'Workspace'],
images: [
{ url: '/images/rooms/deluxe/01.jpg', alt: 'Deluxe Room - Bedroom', isPrimary: true },
{ url: '/images/rooms/deluxe/02.jpg', alt: 'Deluxe Room - Bathroom', isPrimary: false },
{ url: '/images/rooms/deluxe/03.jpg', alt: 'Deluxe Room - Seating Area', isPrimary: false },
{ url: '/images/rooms/deluxe/04.jpg', alt: 'Deluxe Room - View', isPrimary: false }
],
status: 'Available',
isActive: true,
smokingAllowed: false,
petsAllowed: false,
cleaningStatus: 'Clean',
metaTitle: 'Deluxe Room - Old Vine Hotel',
metaDescription: 'Experience comfort and elegance in our spacious Deluxe Room with traditional Damascene decor.'
});
console.log('✅ Created Deluxe Room');
} else {
console.log(' Deluxe Room already exists');
}
const executiveExists = await Room.findOne({ roomNumber: '201' });
if (!executiveExists) {
await Room.create({
name: 'Executive Suite',
type: 'Executive Suite',
slug: 'executive-suite',
description: 'Indulge in luxury with our Executive Suite, offering separate living space, premium amenities, and stunning views of Old Damascus. Ideal for business travelers or those seeking extra space and comfort during their stay.',
shortDescription: 'Premium luxury with separate living area',
roomNumber: '201',
floor: 2,
size: 55,
maxOccupancy: 3,
bedType: 'King',
bedCount: 1,
basePrice: 250,
amenities: ['WiFi', 'TV', 'AC', 'Minibar', 'Safe', 'City View', 'Workspace', 'Balcony', 'Jacuzzi'],
images: [
{ url: '/images/rooms/executive/01.jpg', alt: 'Executive Suite - Living Room', isPrimary: true },
{ url: '/images/rooms/executive/02.jpg', alt: 'Executive Suite - Bedroom', isPrimary: false },
{ url: '/images/rooms/executive/03.jpg', alt: 'Executive Suite - Bathroom', isPrimary: false },
{ url: '/images/rooms/executive/04.jpg', alt: 'Executive Suite - View', isPrimary: false }
],
status: 'Available',
isActive: true,
smokingAllowed: false,
petsAllowed: false,
cleaningStatus: 'Clean',
metaTitle: 'Executive Suite - Old Vine Hotel',
metaDescription: 'Indulge in luxury with our Executive Suite offering separate living space and stunning views.'
});
console.log('✅ Created Executive Suite');
} else {
console.log(' Executive Suite already exists');
}
const presidentialExists = await Room.findOne({ roomNumber: '301' });
if (!presidentialExists) {
await Room.create({
name: 'Presidential Suite',
type: 'Presidential Suite',
slug: 'presidential-suite',
description: 'The epitome of luxury, our Presidential Suite offers unparalleled elegance, spacious living areas, and exclusive amenities for the most discerning guests. Experience the finest accommodation Old Damascus has to offer.',
shortDescription: 'Ultimate luxury and exclusive service',
roomNumber: '301',
floor: 3,
size: 85,
maxOccupancy: 4,
bedType: 'King',
bedCount: 2,
basePrice: 450,
amenities: ['WiFi', 'TV', 'AC', 'Minibar', 'Safe', 'City View', 'Workspace', 'Balcony', 'Jacuzzi', 'Terrace', 'Walk-in Closet', 'Butler Service'],
images: [
{ url: '/images/rooms/presidential/01.jpg', alt: 'Presidential Suite - Main Living Area', isPrimary: true },
{ url: '/images/rooms/presidential/02.jpg', alt: 'Presidential Suite - Master Bedroom', isPrimary: false },
{ url: '/images/rooms/presidential/03.jpg', alt: 'Presidential Suite - Spa Bathroom', isPrimary: false },
{ url: '/images/rooms/presidential/04.jpg', alt: 'Presidential Suite - Private Terrace', isPrimary: false }
],
status: 'Available',
isActive: true,
smokingAllowed: false,
petsAllowed: false,
cleaningStatus: 'Clean',
metaTitle: 'Presidential Suite - Old Vine Hotel',
metaDescription: 'The epitome of luxury with unparalleled elegance, spacious living areas, and exclusive amenities.'
});
console.log('✅ Created Presidential Suite');
} else {
console.log(' Presidential Suite already exists');
}
// ==================== SITE SETTINGS ====================
let settings = await SiteSettings.findOne();
if (!settings) {
settings = await SiteSettings.create({
siteName: 'Old Vine Hotel',
siteDescription: 'Experience luxury and authentic Syrian hospitality in the heart of Old Damascus',
siteKeywords: 'damascus hotel, old damascus, luxury hotel syria, boutique hotel damascus, historic hotel',
contactEmail: 'info@oldvinehotel.com',
contactPhone: '+963 986 703 070',
whatsapp: '+963 986 703 070',
address: {
street: 'Old Damascus City',
city: 'Damascus',
country: 'Syria',
coordinates: {
lat: 33.5138,
lng: 36.2765
}
},
socialMedia: {
facebook: 'https://facebook.com/oldvinehotel',
instagram: 'https://instagram.com/oldvinehotel',
twitter: 'https://twitter.com/oldvinehotel'
},
theme: {
primaryColor: '#8B4513',
secondaryColor: '#D4AF37',
accentColor: '#2C5F2D'
},
bookingSettings: {
minNights: 1,
maxNights: 30,
checkInTime: '14:00',
checkOutTime: '12:00',
cancellationPolicy: 'Free cancellation up to 48 hours before check-in'
},
seo: {
metaTitle: 'Old Vine Hotel - Luxury Accommodation in Old Damascus',
metaDescription: 'Experience timeless elegance and authentic Syrian hospitality at Old Vine Hotel, a beautifully restored historic hotel in the heart of Old Damascus.',
ogImage: '/images/hero.jpg'
}
});
console.log('✅ Created site settings');
} else {
console.log(' Site settings already exist');
}
console.log('\n✅✅✅ CONTENT SEEDING COMPLETED! ✅✅✅\n');
console.log('📊 Summary:');
console.log(' - Homepage content: Ready');
console.log(' - About page content: Ready');
console.log(' - Rooms (3): Deluxe (101), Executive (201), Presidential (301)');
console.log(' - Site settings: Configured');
console.log('\n🔗 Next: Public website will fetch from these entries\n');
await mongoose.connection.close();
} catch (error) {
console.error('Error seeding content:', error);
process.exit(1);
}
};
seedContent();

View File

@@ -0,0 +1,75 @@
require('dotenv').config({ path: require('path').join(__dirname, '../.env') });
const mongoose = require('mongoose');
const GalleryCategory = require('../models/GalleryCategory');
const seedGalleryCategories = async () => {
try {
// Connect to MongoDB
await mongoose.connect(process.env.MONGODB_URI || 'mongodb://localhost:27017/vine_hotel');
console.log('✅ Connected to MongoDB');
const categories = [
{
name: 'Hotel Gallery',
slug: 'hotel-gallery',
description: 'Explore the beautiful interiors, architecture, and spaces of Old Vine Hotel. From elegant rooms to stunning courtyards, discover the charm of our historic property.',
shortDescription: 'Beautiful interiors, architecture, and spaces of our hotel',
displayOrder: 1,
isActive: true,
images: [],
metaTitle: 'Hotel Gallery - Old Vine Hotel',
metaDescription: 'Explore the beautiful interiors and architecture of Old Vine Hotel in Old Damascus.'
},
{
name: 'Restaurant Gallery',
slug: 'restaurant-gallery',
description: 'Take a visual journey through our restaurant and dining spaces. Experience the ambiance, cuisine presentations, and elegant settings where culinary excellence meets authentic Syrian hospitality.',
shortDescription: 'Restaurant ambiance, cuisine, and dining experiences',
displayOrder: 2,
isActive: true,
images: [],
metaTitle: 'Restaurant Gallery - Old Vine Hotel',
metaDescription: 'Explore our restaurant and dining spaces at Old Vine Hotel.'
}
];
// Insert or update categories
for (const categoryData of categories) {
const existingCategory = await GalleryCategory.findOne({ slug: categoryData.slug });
if (existingCategory) {
// Update existing category but preserve images
Object.keys(categoryData).forEach(key => {
if (key !== 'images' || categoryData.images.length > 0) {
existingCategory[key] = categoryData[key];
}
});
await existingCategory.save();
console.log(`✅ Updated category: ${categoryData.name}`);
} else {
const category = new GalleryCategory(categoryData);
await category.save();
console.log(`✅ Created category: ${categoryData.name}`);
}
}
console.log('\n📊 Gallery Categories Summary:');
const allCategories = await GalleryCategory.find().sort({ displayOrder: 1 });
allCategories.forEach(cat => {
console.log(`${cat.name} (${cat.slug}) - ${cat.images.length} images`);
});
console.log('\n✅ Gallery categories seeded successfully!');
console.log('\n📝 Next Steps:');
console.log(' 1. Upload images for each category');
console.log(' 2. Images should be placed in: /client/public/images/gallery/[category-slug]/');
process.exit(0);
} catch (error) {
console.error('❌ Error seeding gallery categories:', error);
process.exit(1);
}
};
seedGalleryCategories();

View File

@@ -0,0 +1,108 @@
require('dotenv').config({ path: require('path').join(__dirname, '../.env') });
const mongoose = require('mongoose');
const RoomCategory = require('../models/RoomCategory');
const seedRoomCategories = async () => {
try {
// Connect to MongoDB
await mongoose.connect(process.env.MONGODB_URI || 'mongodb://localhost:27017/vine_hotel');
console.log('✅ Connected to MongoDB');
// Clear existing categories (optional - comment out if you want to keep existing)
// await RoomCategory.deleteMany({});
// console.log('🗑️ Cleared existing categories');
const categories = [
{
name: 'Single Room',
slug: 'single-room',
description: 'Comfortable single rooms perfect for solo travelers. Each room is thoughtfully designed with modern amenities and traditional Damascene touches.',
shortDescription: 'Perfect for solo travelers with modern amenities',
displayOrder: 1,
isActive: true,
// Images will be added via CMS or manually
// Placeholder structure - actual images should be uploaded via CMS
images: [],
features: ['WiFi', 'TV', 'AC', 'Minibar', 'Safe', 'City View'],
metaTitle: 'Single Rooms - Old Vine Hotel',
metaDescription: 'Comfortable single rooms perfect for solo travelers at Old Vine Hotel in Damascus.'
},
{
name: 'Double Room',
slug: 'double-room',
description: 'Spacious double rooms ideal for couples or business travelers. Features comfortable double beds, elegant furnishings, and stunning views of Old Damascus.',
shortDescription: 'Spacious rooms perfect for couples with elegant furnishings',
displayOrder: 2,
isActive: true,
images: [],
features: ['WiFi', 'TV', 'AC', 'Minibar', 'Safe', 'City View', 'Workspace', 'Balcony'],
metaTitle: 'Double Rooms - Old Vine Hotel',
metaDescription: 'Spacious double rooms with elegant furnishings and stunning views at Old Vine Hotel.'
},
{
name: 'Suite Room',
slug: 'suite-room',
description: 'Luxurious suite rooms offering separate living areas, premium amenities, and exclusive services. Perfect for extended stays or special occasions.',
shortDescription: 'Luxurious suites with separate living areas and premium amenities',
displayOrder: 3,
isActive: true,
images: [],
features: ['WiFi', 'TV', 'AC', 'Minibar', 'Safe', 'City View', 'Workspace', 'Balcony', 'Jacuzzi', 'Terrace'],
metaTitle: 'Suite Rooms - Old Vine Hotel',
metaDescription: 'Luxurious suite rooms with separate living areas at Old Vine Hotel in Damascus.'
},
{
name: 'Twin Room',
slug: 'twin-room',
description: 'Comfortable twin rooms with two separate beds, ideal for friends or family traveling together. Features all modern amenities in a traditional setting.',
shortDescription: 'Comfortable rooms with two beds, perfect for friends or family',
displayOrder: 4,
isActive: true,
images: [],
features: ['WiFi', 'TV', 'AC', 'Minibar', 'Safe', 'City View'],
metaTitle: 'Twin Rooms - Old Vine Hotel',
metaDescription: 'Comfortable twin rooms with two separate beds at Old Vine Hotel.'
}
];
// Insert or update categories
for (const categoryData of categories) {
const existingCategory = await RoomCategory.findOne({ slug: categoryData.slug });
if (existingCategory) {
// Update existing category but preserve images
Object.keys(categoryData).forEach(key => {
if (key !== 'images' || categoryData.images.length > 0) {
existingCategory[key] = categoryData[key];
}
});
await existingCategory.save();
console.log(`✅ Updated category: ${categoryData.name}`);
} else {
const category = new RoomCategory(categoryData);
await category.save();
console.log(`✅ Created category: ${categoryData.name}`);
}
}
console.log('\n📊 Room Categories Summary:');
const allCategories = await RoomCategory.find().sort({ displayOrder: 1 });
allCategories.forEach(cat => {
console.log(`${cat.name} (${cat.slug}) - ${cat.images.length} images`);
});
console.log('\n✅ Room categories seeded successfully!');
console.log('\n📝 Next Steps:');
console.log(' 1. Upload images for each category via CMS admin panel');
console.log(' 2. Assign rooms to categories');
console.log(' 3. Images should be placed in: /client/public/images/rooms/[category-slug]/');
process.exit(0);
} catch (error) {
console.error('❌ Error seeding room categories:', error);
process.exit(1);
}
};
seedRoomCategories();

View File

@@ -0,0 +1,51 @@
require('dotenv').config({ path: require('path').join(__dirname, '../.env') });
const mongoose = require('mongoose');
const Content = require('../models/Content');
const updateAboutPage = async () => {
try {
// Connect to MongoDB
await mongoose.connect(process.env.MONGODB_URI || 'mongodb://localhost:27017/vine_hotel');
console.log('✅ Connected to MongoDB');
// Find and update about page content
let aboutPage = await Content.findOne({ page: 'about' });
if (!aboutPage) {
console.log('📝 About page not found, creating new one...');
aboutPage = new Content({ page: 'about' });
}
// Update heritage section
const heritageSectionIndex = aboutPage.sections.findIndex(s => s.sectionId === 'heritage');
const newHeritageSection = {
sectionId: 'heritage',
title: 'A Hidden Gem Of Old Damascus',
content: `Old Vine Hotel stands as a living piece of history, where centuries-old craftsmanship and modern elegance unite in perfect harmony. the property features three tranquil courtyards, each shaded by climbing vines and fragrant citrus trees, offering guests peaceful spaces to relax and unwind.
From the terraces overlooking old Damascus and the new city, the views are simply breathtaking. the majestic Umayyad mosque feels almost within reach, its minarets visible from the terrace—an unforgettable sight that connects you directly to the heart of one of the world's oldest continuously inhabited cities.`
};
if (heritageSectionIndex !== -1) {
aboutPage.sections[heritageSectionIndex] = newHeritageSection;
} else {
aboutPage.sections.push(newHeritageSection);
}
await aboutPage.save();
console.log('✅ About page heritage section updated successfully!');
console.log('\n📝 Heritage Section:');
const heritageSection = aboutPage.sections.find(s => s.sectionId === 'heritage');
console.log('Title:', heritageSection.title);
console.log('Content:', heritageSection.content.substring(0, 150) + '...');
process.exit(0);
} catch (error) {
console.error('❌ Error updating about page:', error);
process.exit(1);
}
};
updateAboutPage();

View File

@@ -0,0 +1,94 @@
require('dotenv').config({ path: require('path').join(__dirname, '../.env') });
const mongoose = require('mongoose');
const RoomCategory = require('../models/RoomCategory');
const fs = require('fs');
const path = require('path');
const updateCategoryImages = async () => {
try {
// Connect to MongoDB
await mongoose.connect(process.env.MONGODB_URI || 'mongodb://localhost:27017/vine_hotel');
console.log('✅ Connected to MongoDB');
// Define categories and their directories
const categories = [
{ slug: 'single-room', name: 'Single Room' },
{ slug: 'double-room', name: 'Double Room' },
{ slug: 'suite-room', name: 'Suite Room' },
{ slug: 'twin-room', name: 'Twin Room' }
];
const imagesBasePath = path.join(__dirname, '../../client/public/images/rooms');
for (const categoryInfo of categories) {
const categoryDir = path.join(imagesBasePath, categoryInfo.slug);
// Check if directory exists
if (!fs.existsSync(categoryDir)) {
console.log(`⚠️ Directory not found: ${categoryDir}`);
continue;
}
// Read all files in directory
const files = fs.readdirSync(categoryDir)
.filter(file => {
const ext = path.extname(file).toLowerCase();
return ['.jpg', '.jpeg', '.png', '.webp'].includes(ext);
})
.sort((a, b) => {
// Sort by filename numerically (01.jpg, 02.jpg, etc.)
const numA = parseInt(a.match(/\d+/)?.[0] || '0');
const numB = parseInt(b.match(/\d+/)?.[0] || '0');
return numA - numB;
});
if (files.length === 0) {
console.log(`⚠️ No images found in ${categoryInfo.slug}`);
continue;
}
// Build images array
const images = files.map((file, index) => ({
url: `/images/rooms/${categoryInfo.slug}/${file}`,
alt: `${categoryInfo.name} - Image ${index + 1}`,
isPrimary: index === 0, // First image is primary
order: index
}));
// Find and update category
const category = await RoomCategory.findOne({ slug: categoryInfo.slug });
if (!category) {
console.log(`⚠️ Category not found in database: ${categoryInfo.slug}`);
continue;
}
// Update category with images
category.images = images;
await category.save();
console.log(`✅ Updated ${categoryInfo.name}: ${images.length} images`);
console.log(` Primary image: ${images[0].url}`);
}
// Summary
console.log('\n📊 Summary:');
const allCategories = await RoomCategory.find().sort({ displayOrder: 1 });
for (const cat of allCategories) {
console.log(`${cat.name}: ${cat.images.length} images`);
if (cat.images.length > 0) {
const primary = cat.images.find(img => img.isPrimary) || cat.images[0];
console.log(` Primary: ${primary.url}`);
}
}
console.log('\n✅ All category images updated successfully!');
process.exit(0);
} catch (error) {
console.error('❌ Error updating category images:', error);
process.exit(1);
}
};
updateCategoryImages();

View File

@@ -0,0 +1,92 @@
require('dotenv').config({ path: require('path').join(__dirname, '../.env') });
const mongoose = require('mongoose');
const GalleryCategory = require('../models/GalleryCategory');
const fs = require('fs');
const path = require('path');
const updateGalleryCategoryImages = async () => {
try {
// Connect to MongoDB
await mongoose.connect(process.env.MONGODB_URI || 'mongodb://localhost:27017/vine_hotel');
console.log('✅ Connected to MongoDB');
// Define categories and their directories
const categories = [
{ slug: 'hotel-gallery', name: 'Hotel Gallery' },
{ slug: 'restaurant-gallery', name: 'Restaurant Gallery' }
];
const imagesBasePath = path.join(__dirname, '../../client/public/images/gallery');
for (const categoryInfo of categories) {
const categoryDir = path.join(imagesBasePath, categoryInfo.slug);
// Check if directory exists
if (!fs.existsSync(categoryDir)) {
console.log(`⚠️ Directory not found: ${categoryDir}`);
continue;
}
// Read all files in directory
const files = fs.readdirSync(categoryDir)
.filter(file => {
const ext = path.extname(file).toLowerCase();
return ['.jpg', '.jpeg', '.png', '.webp'].includes(ext);
})
.sort((a, b) => {
// Sort by filename numerically (01.jpg, 02.jpg, etc.)
const numA = parseInt(a.match(/\d+/)?.[0] || '0');
const numB = parseInt(b.match(/\d+/)?.[0] || '0');
return numA - numB;
});
if (files.length === 0) {
console.log(`⚠️ No images found in ${categoryInfo.slug}`);
continue;
}
// Build images array
const images = files.map((file, index) => ({
url: `/images/gallery/${categoryInfo.slug}/${file}`,
alt: `${categoryInfo.name} - Image ${index + 1}`,
isPrimary: index === 0, // First image is primary
order: index
}));
// Find and update category
const category = await GalleryCategory.findOne({ slug: categoryInfo.slug });
if (!category) {
console.log(`⚠️ Category not found in database: ${categoryInfo.slug}`);
continue;
}
// Update category with images
category.images = images;
await category.save();
console.log(`✅ Updated ${categoryInfo.name}: ${images.length} images`);
console.log(` Primary image: ${images[0].url}`);
}
// Summary
console.log('\n📊 Summary:');
const allCategories = await GalleryCategory.find().sort({ displayOrder: 1 });
for (const cat of allCategories) {
console.log(`${cat.name}: ${cat.images.length} images`);
if (cat.images.length > 0) {
const primary = cat.images.find(img => img.isPrimary) || cat.images[0];
console.log(` Primary: ${primary.url}`);
}
}
console.log('\n✅ All gallery category images updated successfully!');
process.exit(0);
} catch (error) {
console.error('❌ Error updating gallery category images:', error);
process.exit(1);
}
};
updateGalleryCategoryImages();

View File

@@ -0,0 +1,46 @@
require('dotenv').config({ path: require('path').join(__dirname, '../.env') });
const mongoose = require('mongoose');
const Content = require('../models/Content');
const updateHeroContent = async () => {
try {
// Connect to MongoDB
await mongoose.connect(process.env.MONGODB_URI || 'mongodb://localhost:27017/vine_hotel');
console.log('✅ Connected to MongoDB');
// Find and update homepage content
const homepage = await Content.findOne({ page: 'home' });
if (!homepage) {
console.error('❌ Homepage content not found');
process.exit(1);
}
// Update hero section
homepage.hero = {
title: 'Your Home Away From Home',
subtitle: 'Experience Damascus Like Never Before',
description: `Hidden within the winding alleys of the ancient city of Old Damascus, Old Vine Hotel is a 5-star boutique haven that captures the essence of Syria's timeless charm. Once three historic damascene homes, the properties have been lovingly restored and seamlessly connected to create an intimate sanctuary of 25 beautifully designed rooms and suites.
Each corner whispers stories of the past, where handcrafted wood, marble courtyards, and elegant fountains blend effortlessly with modern comfort and sophistication. from the moment you step inside, you are embraced by an atmosphere of serenity, authenticity, and understated luxury—a true reflection of Damascus at its beauty.`,
backgroundImage: '/images/hero.jpg',
ctaText: 'Explore Rooms',
ctaLink: '/rooms'
};
await homepage.save();
console.log('✅ Hero content updated successfully!');
console.log('\n📝 New content:');
console.log('Title:', homepage.hero.title);
console.log('Subtitle:', homepage.hero.subtitle);
console.log('Description:', homepage.hero.description.substring(0, 100) + '...');
process.exit(0);
} catch (error) {
console.error('❌ Error updating hero content:', error);
process.exit(1);
}
};
updateHeroContent();

View File

@@ -0,0 +1,70 @@
require('dotenv').config({ path: require('path').join(__dirname, '../.env') });
const mongoose = require('mongoose');
const Content = require('../models/Content');
const updateWelcomeSection = async () => {
try {
// Connect to MongoDB
await mongoose.connect(process.env.MONGODB_URI || 'mongodb://localhost:27017/vine_hotel');
console.log('✅ Connected to MongoDB');
// Find and update homepage content
const homepage = await Content.findOne({ page: 'home' });
if (!homepage) {
console.error('❌ Homepage content not found');
process.exit(1);
}
// Revert hero section to original
homepage.hero = {
title: 'Your Home Away From Home',
subtitle: 'Experience Damascus Like Never Before',
description: 'Nestled in the historic heart of Old Damascus, Old Vine Hotel offers an unforgettable blend of traditional Syrian architecture and modern luxury. Each room tells a story, each corner whispers history, and every moment creates lasting memories.',
backgroundImage: '/images/hero.jpg',
ctaText: 'Explore Rooms',
ctaLink: '/rooms'
};
// Update welcome section (the area below the hero)
const welcomeSectionIndex = homepage.sections.findIndex(s => s.sectionId === 'welcome');
if (welcomeSectionIndex !== -1) {
homepage.sections[welcomeSectionIndex] = {
sectionId: 'welcome',
title: 'Your Home Away From Home',
subtitle: 'Experience Damascus Like Never Before',
content: `Hidden within the winding alleys of the ancient city of Old Damascus, Old Vine Hotel is a 5-star boutique haven that captures the essence of Syria's timeless charm. Once three historic damascene homes, the properties have been lovingly restored and seamlessly connected to create an intimate sanctuary of 25 beautifully designed rooms and suites.
Each corner whispers stories of the past, where handcrafted wood, marble courtyards, and elegant fountains blend effortlessly with modern comfort and sophistication. from the moment you step inside, you are embraced by an atmosphere of serenity, authenticity, and understated luxury—a true reflection of Damascus at its beauty.`
};
} else {
// Add welcome section if it doesn't exist
homepage.sections.push({
sectionId: 'welcome',
title: 'Your Home Away From Home',
subtitle: 'Experience Damascus Like Never Before',
content: `Hidden within the winding alleys of the ancient city of Old Damascus, Old Vine Hotel is a 5-star boutique haven that captures the essence of Syria's timeless charm. Once three historic damascene homes, the properties have been lovingly restored and seamlessly connected to create an intimate sanctuary of 25 beautifully designed rooms and suites.
Each corner whispers stories of the past, where handcrafted wood, marble courtyards, and elegant fountains blend effortlessly with modern comfort and sophistication. from the moment you step inside, you are embraced by an atmosphere of serenity, authenticity, and understated luxury—a true reflection of Damascus at its beauty.`
});
}
await homepage.save();
console.log('✅ Hero section reverted to original!');
console.log('✅ Welcome section updated successfully!');
console.log('\n📝 Welcome Section:');
const welcomeSection = homepage.sections.find(s => s.sectionId === 'welcome');
console.log('Title:', welcomeSection.title);
console.log('Subtitle:', welcomeSection.subtitle);
console.log('Content:', welcomeSection.content.substring(0, 100) + '...');
process.exit(0);
} catch (error) {
console.error('❌ Error updating content:', error);
process.exit(1);
}
};
updateWelcomeSection();