Add docs, robots.txt and fix migration syntax

- backend/README.md: full API and DB documentation
- public/robots.txt: block all pages except root for SEO
- index.html: add noindex meta tag for inner SPA pages
- 002_extend.sql: fix RENAME COLUMN syntax (remove unsupported IF EXISTS)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-17 13:33:27 +03:00
parent ef1603d896
commit 17dbf629a2
4 changed files with 157 additions and 2 deletions

149
backend/README.md Normal file
View File

@@ -0,0 +1,149 @@
# HotelSync — Backend API
Fastify + TypeScript + PostgreSQL + Redis
## Stack
- **Runtime**: Node.js 20
- **Framework**: Fastify 4
- **Database**: PostgreSQL 16
- **Cache / Sessions**: Redis 7
- **Auth**: JWT (access 1h) + opaque refresh token (30d, stored in Redis)
- **Language**: TypeScript (strict mode off for unused vars)
## API Base URL
```
https://api.hotelsync.ru
```
## Auth
```
POST /api/auth/login { email, password } → { token, refreshToken, user }
POST /api/auth/refresh { refreshToken } → { token }
POST /api/auth/logout
GET /api/auth/me
```
All protected routes require `Authorization: Bearer <token>`.
## Routes
```
GET /api/hotels (super_admin)
POST /api/hotels (super_admin)
GET /api/hotels/:slug/rooms
POST /api/hotels/:slug/rooms
PATCH /api/hotels/:slug/rooms/:id
DELETE /api/hotels/:slug/rooms/:id
GET /api/hotels/:slug/bookings
POST /api/hotels/:slug/bookings
PATCH /api/hotels/:slug/bookings/:id
GET /api/hotels/:slug/guests
POST /api/hotels/:slug/guests
PATCH /api/hotels/:slug/guests/:id
GET /api/hotels/:slug/housekeeping
POST /api/hotels/:slug/housekeeping
PATCH /api/hotels/:slug/housekeeping/:id
GET /api/hotels/:slug/users
POST /api/hotels/:slug/users
PATCH /api/hotels/:slug/users/:id
GET /api/hotels/:slug/channels
PATCH /api/hotels/:slug/channels/:id
GET /api/hotels/:slug/tariffs
POST /api/hotels/:slug/tariffs
PATCH /api/hotels/:slug/tariffs/:id
GET /api/hotels/:slug/discounts
POST /api/hotels/:slug/discounts
PATCH /api/hotels/:slug/discounts/:id
GET /api/hotels/:slug/reviews
POST /api/hotels/:slug/reviews
PATCH /api/hotels/:slug/reviews/:id
GET /api/hotels/:slug/maintenance
POST /api/hotels/:slug/maintenance
PATCH /api/hotels/:slug/maintenance/:id
GET /api/hotels/:slug/pos/categories
GET /api/hotels/:slug/pos/items
GET /api/hotels/:slug/pos/orders
POST /api/hotels/:slug/pos/orders
# CP Admin panel (super_admin only)
GET /api/admin/hotels
POST /api/admin/hotels
PATCH /api/admin/hotels/:id
GET /api/admin/users
POST /api/admin/users
PATCH /api/admin/users/:id
```
## Database Migrations
Migrations run automatically on container startup (in order).
| File | Description |
|------|-------------|
| `migrations/001_schema.sql` | Base schema: hotels, rooms, bookings, users, channels, housekeeping |
| `migrations/002_extend.sql` | Extended schema: guests, tariffs, discounts, loyalty, reviews, maintenance, POS, document templates, hotel settings |
### Key tables
| Table | Description |
|-------|-------------|
| `hotels` | Hotels with plan, contact info, check-in/out times |
| `rooms` | Rooms with beds JSONB, extra_place JSONB, child_policy JSONB |
| `room_categories` | Room categories per hotel |
| `guests` | Guest database with loyalty points/tiers |
| `bookings` | Bookings with guest_id, payment_status, meal_plan |
| `tariffs` | Pricing tariffs (percent / fixed / multiplier) |
| `discounts` | Discounts and promo codes |
| `loyalty_rules` | Point accrual rules (stay, review, birthday...) |
| `loyalty_tiers` | Tier thresholds (standard/silver/gold/platinum) |
| `reviews` | Guest reviews from all sources |
| `maintenance_tasks` | Maintenance tasks per room |
| `pos_categories` | POS item categories |
| `pos_items` | POS menu items with price and VAT |
| `pos_orders` | POS orders with JSONB items |
| `document_templates` | HTML templates for registration cards, invoices |
| `hotel_settings` | Key-value JSONB settings per hotel |
## Demo accounts (seeded automatically)
| Email | Password | Role |
|-------|----------|------|
| admin@hotelsync.io | demo | super_admin |
| manager@grand-palace.ru | demo | hotel_manager |
| cleaner@grand-palace.ru | demo | housekeeper |
## Running locally
```bash
cd backend
npm install
npm run dev
```
Requires `.env`:
```
DATABASE_URL=postgres://hotelsync:password@localhost:5432/hotelsync
REDIS_URL=redis://localhost:6379
JWT_SECRET=your-secret
```
## Docker
```bash
docker build -t hotelsync-api .
docker run -p 3000:3000 --env-file .env hotelsync-api
```

View File

@@ -44,8 +44,8 @@ ALTER TABLE rooms
ADD COLUMN IF NOT EXISTS photos TEXT[] NOT NULL DEFAULT '{}';
-- Переименуем старые поля для единообразия
ALTER TABLE rooms RENAME COLUMN IF EXISTS capacity TO max_guests;
ALTER TABLE rooms RENAME COLUMN IF EXISTS price_per_night TO base_rate;
ALTER TABLE rooms RENAME COLUMN capacity TO max_guests;
ALTER TABLE rooms RENAME COLUMN price_per_night TO base_rate;
-- ── Guests (база гостей) ────────────────────────────────────────────────────
CREATE TABLE IF NOT EXISTS guests (

View File

@@ -5,6 +5,7 @@
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="HotelSync — современная PMS система для отелей" />
<meta name="robots" content="noindex, nofollow" />
<title>HotelSync</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />

5
public/robots.txt Normal file
View File

@@ -0,0 +1,5 @@
User-agent: *
Allow: /$
Disallow: /
Sitemap: https://app.hotelsync.ru/sitemap.xml