Reserve Now

// server.js - Single-file Node.js Express server with embedded frontend const express = require('express'); const nodemailer = require('nodemailer'); const sqlite3 = require('sqlite3').verbose(); const bodyParser = require('body-parser'); const app = express(); const PORT = 3000; // --- DATABASE SETUP --- const db = new sqlite3.Database(':memory:'); db.serialize(() => { db.run(`CREATE TABLE bookings ( id INTEGER PRIMARY KEY AUTOINCREMENT, date TEXT NOT NULL, slot TEXT NOT NULL )`); }); app.use(bodyParser.json()); // --- EMAIL SETUP --- (using Gmail SMTP) const transporter = nodemailer.createTransport({ service: 'gmail', auth: { user: 'ranenbechthold@gmail.com', pass: 'YOUR_APP_PASSWORD_HERE' // Use an app password } }); // --- FRONTEND PAGE --- const html = ` Bounce House Booking

Book the Bounce House

`; app.get('/', (req, res) => { res.send(html); }); // --- CHECK & CREATE BOOKING --- app.post('/book', (req, res) => { const { date, slot } = req.body; if (!date || !slot) return res.json({ message: 'Missing fields.' }); db.all(`SELECT * FROM bookings WHERE date = ?`, [date], (err, rows) => { if (err) return res.json({ message: 'Database error.' }); const isBooked = rows.some(r => r.slot === slot || r.slot === 'double' || slot === 'double'); if (isBooked) { return res.json({ message: 'This date and time slot is already booked.' }); } db.run(`INSERT INTO bookings (date, slot) VALUES (?, ?)`, [date, slot], function () { transporter.sendMail({ from: 'ranenbechthold@gmail.com', to: 'ranenbechthold@gmail.com', subject: 'New Bounce House Booking', text: `A new booking was made:\nDate: ${date}\nSlot: ${slot}` }); res.json({ message: 'Booking confirmed! A confirmation email has been sent.' }); }); }); }); app.listen(PORT, () => console.log(`Server running on port ${PORT}`));