REST API backend for a Booking Platform — built with Node.js, Express, Prisma & MySQL. Includes JWT authentication, seed data, OpenAPI spec, and Postman test collections.
- Node.js + Express.js
- Prisma ORM
- MySQL
- JWT Authentication
- Winston (logging)
- Sentry (error monitoring)
- Newman (API testing)
git clone https://github.com/aelyakoubi/booking-platform-api.git
cd booking-platform-apinpm installCopy .env.example to .env and fill in your own values:
cp .env.example .envAUTH_SECRET_KEY=your_secret_key_here
DATABASE_URL=mysql://user:password@localhost:3306/your_database_name
SHADOW_DATABASE_URL=mysql://user:password@localhost:3306/your_database_name_shadow
SENTRY_DSN=your_sentry_dsn_herenpx prisma generatenpx prisma db push --force-resetnpm run seednpm run devServer runs on http://localhost:3000
| Resource | Endpoint |
|---|---|
| Users | /users |
| Bookings | /bookings |
| Properties | /properties |
| Reviews | /reviews |
| Hosts | /hosts |
| Amenities | /amenities |
| Login | /login |
Full API documentation is available in openapi.yaml.
Tests are run using Newman (Postman CLI). The collections are located in the postman/ folder.
npm run devnpm run testOr run them separately:
npm run test-positive
npm run test-negative
⚠️ Some tests useDELETEendpoints and modify the database. Re-seed before re-running tests:npm run seed
Located in postman/environments/. Default base URL is http://localhost:3000. Update if your port differs.
npx prisma studioOpens at http://localhost:5555
├── src/
│ ├── data/ # Seed data (JSON)
│ │ ├── amenities.json
│ │ ├── bookings.json
│ │ ├── hosts.json
│ │ ├── properties.json
│ │ ├── reviews.json
│ │ └── users.json
│ ├── errors/
│ │ └── NotFoundError.js # Custom error class
│ ├── middleware/
│ │ ├── auth.js # JWT authentication
│ │ ├── errorHandler.js # Global error handler
│ │ ├── logMiddleware.js # Request logging
│ │ └── notFoundErrorHandler.js
│ ├── routes/
│ │ ├── amenities.js
│ │ ├── bookings.js
│ │ ├── hosts.js
│ │ ├── login.js
│ │ ├── properties.js
│ │ ├── reviews.js
│ │ └── users.js
│ ├── services/ # Business logic per resource
│ │ ├── amenities/
│ │ ├── auth/
│ │ ├── bookings/
│ │ ├── hosts/
│ │ ├── properties/
│ │ ├── reviews/
│ │ └── users/
│ ├── utils/
│ │ └── log.js
│ └── index.js # App entry point
├── prisma/
│ ├── migrations/ # Database migration history
│ ├── schema.prisma # Data model
│ └── seed.js # Seed script
├── postman/
│ ├── collections/ # Positive & negative test collections
│ └── environments/ # Local environment config
├── openapi.yaml # API documentation
├── .env.example # Environment variable template
├── .gitignore
└── package.json

