Server Setup
Node.js booking server using Express, Prisma ORM, and PostgreSQL.
Features
Installation & Configuration
Prerequisites
Ensure your development environment meets these requirements before proceeding:
Install PostgreSQL
A running PostgreSQL instance is required. If not installed, use the following methods:
brew install postgresql
brew services start postgresqlDownload the installer from the official website.
Database Setup
Create a fresh database for the project. You can use terminal commands or a GUI client like TablePlus or pgAdmin.
createdb booking_dbProject Setup
Download the project source code and extract it to your desired folder.
After extracting, navigate to the server folder and install dependencies. This will automatically generate the Prisma client and seed initial data.
cd server
npm install.env file must contain a valid DATABASE_URL:postgresql://user:pass@localhost:5432/booking_db?schema=publicEmail: admin@admin.com | Password: admin
Authentication Configuration
Generate a secure JWT_SECRET to sign authentication tokens. Use a long random string.
JWT_SECRET="your_custom_secure_string_here"Service Integration (Stripe & Cloudinary)
Configure payments and asset management by modifying the local .env file adding the following keywords with their respective values from your third-party service provider accounts.
Stripe Configuration
For secure payment processing and guest transactions.
2. Navigate to Developers > API keys to find your Secret key (sk_test_...).
STRIPE_SECRET_KEY="sk_test_..."- Activate your account by completing the business profile.
- Switch the Test mode toggle to Live.
- Use the Live Secret Key (sk_live_...) in your production environment variables.
Cloudinary Setup
Cloud-based management for room images and assets.
2. Copy Cloud Name, API Key, and API Secret from your Dashboard.
CLOUDINARY_CLOUD_NAME="..."
CLOUDINARY_API_KEY="..."
CLOUDINARY_API_SECRET="..."Email Engine
Configure your SMTP settings for automated guest notifications and booking confirmations.
You can use services like Gmail, SendGrid, Mailgun, or any custom SMTP server.
EMAIL_HOST="smtp.example.com"
EMAIL_PORT="587"
EMAIL_USER="your_email_user"
EMAIL_PASS="your_email_password"
EMAIL_FROM_ADDRESS="noreply@example.com"Important: Use an App Password for the EMAIL_PASS field if using two-factor authentication.
iCal Synchronization
The system supports bidirectional synchronization via iCalendar feeds, ensuring your availability is always up to date across all platforms.
Each room has a unique URL that exposes its current bookings to external platforms.
https://your-api.com/api/ical/export/:roomId- Extranet > Rates & Availability > Calendar
- Sync calendars > Add connection
- Paste your unique export URL
Import feeds from external platforms to block dates in your system automatically.
Modify src/config/icalFeeds.ts:
export const EXTERNAL_ICAL_FEEDS = [
{
channelName: 'Booking.com',
roomId: 1,
icalUrl: 'https://ical.booking.com/...'
}
];- Extranet > Rates & Availability > Calendar
- Click Export calendar to get iCal link
- Copy and paste into your config array
Deployment & Vercel
Go live with a single command. The system is fully optimized for Vercel's edge infrastructure.
Vercel Edge CLI
Production-ready deployment
vercel --prodPOSTGRES_PRISMA_URL to DATABASE_URL in your Vercel project settings to enable the database connection.📂 Directory Structure
- prisma/
- schema.prisma
- seed.ts
- src/
- controllers/
- bookingController.ts
- routes/
- bookingRoutes.ts
- services/
- stripeService.ts
- config/
- icalFeeds.ts
- middleware/
- .env
- package.json