diff --git a/.env.example b/.env.example index 7189b0e..418ae12 100644 --- a/.env.example +++ b/.env.example @@ -1,19 +1,22 @@ # Hotel 777 - Environment Configuration -# Copy this file to .env and fill in your values +# Copy this file to .env and fill in your values: cp .env.example .env +# +# ⚠️ HOTEL777KEY и JWT_SECRET обязательны - без них сервер не запустится! +# ⚠️ JWT_SECRET должен быть не менее 32 символов -# API Key for external access (required) +# API-ключ для внешнего доступа к бронированиям (обязателен) HOTEL777KEY=your-secret-api-key-here -# JWT Secret for token signing (required) - minimum 32 characters +# Секретный ключ для подписи JWT токенов (обязателен) — минимум 32 символа JWT_SECRET=your-jwt-secret-min-32-characters-here -# Admin credentials (required for first run) +# Учетные данные суперадмина (нужны для первого запуска) ADMIN_LOGIN=admin ADMIN_PASSWORD=your-admin-password -# Monitoring credentials (optional) +# Мониторинг Prometheus /metrics (опционально, значения по умолчанию указаны) MONITORING_USER=monitoring MONITORING_PASSWORD=monitoring123 -# Server port (optional, default: 3000) -# PORT=3000 \ No newline at end of file +# Порт сервера (опционально, по умолчанию 3000) +PORT=3000 \ No newline at end of file diff --git a/.gitea/workflows/run.yml b/.gitea/workflows/run.yml new file mode 100644 index 0000000..a5b9008 --- /dev/null +++ b/.gitea/workflows/run.yml @@ -0,0 +1,19 @@ +name: Deploy hotel + +# Триггеры запуска +on: +# push: +# branches: + - main # автоматический запуск при пуше в main +# workflow_dispatch: # ручной запуск через интерфейс Gitea (кнопка "Run workflow") + +jobs: + deploy-kdo: + runs-on: kdo + steps: + - name: clear zhelcrm + run: docker system prune -af + - name: Deploy + run: | + cd /docker/hotell777_260507 && docker compose build --no-cache && docker compose up -d +# \ No newline at end of file diff --git a/.gitignore b/.gitignore index 91c8c7c..8ce182b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ node_modules package-lock.json .env /data/ -promt \ No newline at end of file +promt +*.log \ No newline at end of file diff --git a/modules/adminBookings/index.js b/modules/adminBookings/index.js index 9093c7a..17aaa47 100644 --- a/modules/adminBookings/index.js +++ b/modules/adminBookings/index.js @@ -1,5 +1,3 @@ -const bcrypt = require('bcryptjs'); -const jwt = require('jsonwebtoken'); const config = require('../../config'); const promocodeRateLimit = new Map(); @@ -34,11 +32,9 @@ setInterval(() => { }, PROMOCODE_WINDOW); let db; -let JWT_SECRET; -function init(database, jwtSecret) { +function init(database) { db = database; - JWT_SECRET = jwtSecret; } function validatePromocode(promocode, callback) { @@ -299,11 +295,11 @@ function updateBookingDetails(req, res) { if (!roomType) { return finishUpdate(); } - db.get(`SELECT price_per_guest FROM rooms WHERE type = ? AND is_active = 1`, [roomType], (err, roomData) => { + db.get(`SELECT price_per_night FROM rooms WHERE type = ? AND is_active = 1`, [roomType], (err, roomData) => { if (err) return res.status(500).json({ error: 'Database error' }); - const pricePerGuest = roomData ? roomData.price_per_guest : config.getRoomPrice(roomType); + const pricePerNight = roomData ? roomData.price_per_night : config.getRoomPrice(roomType); const nights = config.calculateNights(finalCheckin, finalCheckout); - const basePrice = pricePerGuest * totalGuests * nights; + const basePrice = pricePerNight * totalGuests * nights; const discountPercent = row.discount_percent || 0; const discountAmount = Math.round(basePrice * discountPercent / 100); const totalPrice = basePrice - discountAmount; diff --git a/public/admin.html b/public/admin.html index a4110aa..c3a121f 100644 --- a/public/admin.html +++ b/public/admin.html @@ -10,35 +10,37 @@ @@ -171,7 +194,9 @@ tr.row-checkout-today { background: #fef2f2 !important; border-left: 4px solid #
-