This is the backend API for the Pizza Booking application, built with Node.js, Express, and MongoDB.
- RESTful API for a pizza ordering platform
- User authentication and authorization with JWT
- Order management and processing
- Email notifications via Nodemailer
- Web push notifications support
- Compatible with Vercel deployment
- Node.js - JavaScript runtime
- Express - Web framework
- MongoDB - Database
- Mongoose - MongoDB object modeling
- JWT - Authentication
- Bcrypt - Password hashing
- Nodemailer - Email functionality
- Web-Push - Push notifications
- Clone the repository
- Install dependencies:
npm install - Create a
.envfile in the root directory with the following variables:PORT=5000 MONGODB_URI=your_mongodb_connection_string JWT_SECRET=your_jwt_secret EMAIL_SERVICE=gmail EMAIL_USER=your_email@gmail.com EMAIL_PASS=your_email_app_password VAPID_PUBLIC_KEY=your_vapid_public_key VAPID_PRIVATE_KEY=your_vapid_private_key
npm start- Start the server in production modenpm run dev- Start the server in development mode with nodemonnpm run test-email- Test email functionalitynpm run test-vercel-email- Test Vercel email functionalitynpm run process-emails- Process emails in the queuenpm run email-diagnostic- Run email diagnosticnpm run ensure-vercel-email- Ensure Vercel email setupnpm run generate-vapid- Generate VAPID keys for web pushnpm run safe-start- Kill any process on the configured port and start servernpm run safe-dev- Kill any process on the configured port and start dev server
POST /api/auth/register- Register a new userPOST /api/auth/login- Login a user
GET /api/pizzas- Get all pizzasGET /api/pizzas/:id- Get a specific pizza
POST /api/orders- Create a new orderGET /api/orders- Get all orders (admin)GET /api/orders/user- Get current user's ordersGET /api/orders/:id- Get a specific orderPUT /api/orders/:id- Update an order status (admin)
GET /api/users/profile- Get current user profilePUT /api/users/profile- Update user profilePUT /api/users/password- Change password
The application includes email notification capabilities for order confirmations and status updates. Several utility scripts are included to test and configure email functionality:
testEmail.js- Basic email testingsrc/vercelEmailTest.js- Testing email in Vercel environmentsrc/processEmailQueue.js- Process queued emails (for reliability)src/fixVercelEmail.js- Diagnostic for Vercel email issuessrc/ensureVercelEmail.js- Setup for Vercel email
The server maintains a simple notification system for tracking orders. You can view these notifications by accessing the /notifications endpoint.
This application is configured for deployment on Vercel with the included vercel.json configuration file.