Backend: - POST /api/events/:id/guests — add guest, auto-generate RSVP token (128-bit crypto.randomBytes), build wa.me WhatsApp deep-link, store in invitations - GET /api/events/:id/guests — list with pg_trgm fuzzy Hebrew name search, status filter, pagination; returns RSVP summary + capacity warning at 90% - GET /api/events/:id/guests/export — CSV export with UTF-8 BOM for Excel Hebrew support (json2csv) - PUT /api/guests/:id — PATCH-style update (COALESCE), organizer ownership check - DELETE /api/guests/:id — hard delete per Israeli Privacy Law 2023 - GET /api/rsvp/:token — public (no auth), marks opened_at on first visit - POST /api/rsvp/:token — idempotent RSVP submit, supports dietary update, handles cancelled events (410) - Israeli phone normalization: 05X-XXXXXXX → +972XXXXXXXXX E.164 - Capacity warning returned in add/list/update responses when confirmed ≥ 90% of venue_capacity (fire safety compliance) Frontend: - GuestListPage — sortable/filterable table, inline RSVP status override, WhatsApp send links, delete with confirmation, 30s polling for real-time updates - AddGuestForm — RTL Hebrew form, all guest fields, shows WhatsApp link on success - RsvpSummaryCard — 4-metric summary (total/confirmed/declined/pending) + capacity warning - RsvpPage — public page at /rsvp/:token, shows event details, confirm/decline, dietary preference update; no login required - New UI components: Badge, Select (shadcn/ui compatible) - App.tsx: added /events/:eventId/guests (protected) and /rsvp/:token (public) routes Build: 0 TS errors, all routes wired in server.js Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
46 lines
1.3 KiB
JavaScript
46 lines
1.3 KiB
JavaScript
require('dotenv').config();
|
|
const express = require('express');
|
|
const cookieParser = require('cookie-parser');
|
|
const cors = require('cors');
|
|
const path = require('path');
|
|
|
|
const authRoutes = require('./routes/auth');
|
|
const guestRoutes = require('./routes/guests');
|
|
const rsvpRoutes = require('./routes/rsvp');
|
|
const { authMiddleware } = require('./middleware/auth');
|
|
|
|
const app = express();
|
|
const PORT = process.env.PORT || 3000;
|
|
|
|
app.use(cors({
|
|
origin: process.env.CLIENT_ORIGIN || true,
|
|
credentials: true,
|
|
}));
|
|
app.use(express.json());
|
|
app.use(cookieParser());
|
|
|
|
// Health check — no auth required
|
|
app.get('/health', (req, res) => res.json({ status: 'ok' }));
|
|
|
|
// Auth routes — no middleware (register/login are public)
|
|
app.use('/api/auth', authRoutes);
|
|
|
|
// Public RSVP routes — no auth required
|
|
app.use('/api/rsvp', rsvpRoutes);
|
|
|
|
// All routes below require valid JWT
|
|
app.use('/api', authMiddleware);
|
|
|
|
// Guest management routes (auth enforced above)
|
|
app.use('/api', guestRoutes);
|
|
|
|
// Serve React frontend in production
|
|
app.use(express.static(path.join(__dirname, 'client', 'dist')));
|
|
app.get('*', (req, res) => {
|
|
res.sendFile(path.join(__dirname, 'client', 'dist', 'index.html'));
|
|
});
|
|
|
|
app.listen(PORT, () => {
|
|
console.log(`אירועית server running on port ${PORT}`);
|
|
});
|