A RESTful API for a mock flight booking system built using Node.js, Express, and MongoDB.
- Search available flights
- Book a flight
- Cancel a booking
- User registration and authentication
- MongoDB-based storage
- Node.js
- Express
- MongoDB
- Mongoose
- dotenv
- MongoDB Compass (for GUI access)
git clone https://github.com/ramjangatisetty/flight-booking-api.git
cd flight-booking-apinpm installCreate a .env file in the root directory:
PORT=5000
MONGODB_URI=mongodb://localhost:27017/flight-booking
You can change
MONGODB_URIbased on your local or cloud MongoDB setup.
npm startServer will be running at http://localhost:5000
-
Connection String:
mongodb://localhost:27017/flight-booking -
Open
flights,users,bookingscollections
mongoimport --db flight-booking --collection flights --file seed/flights.json --jsonArrayMake sure MongoDB is running before executing the above.
mongo
use flight-booking
db.flights.insertMany(require('./seed/flights.json'))GET /api/flightsPOST /api/bookings
Content-Type: application/json
{
"userId": "123456",
"flightId": "abcdef"
}DELETE /api/bookings/:bookingId- Add payment gateway integration
- Improve user session management with JWT refresh tokens
- Add Swagger/OpenAPI documentation
Feel free to fork this repo and raise a pull request.
MIT