This is Air Ticket Booking System where user can register with their credentials and login with their credentials and after authentication user can view the flights and book flights , edit the booked flights , and delete the booking.
https://github.com/Amanmandal-M/Mock_6_Backend.git
npm install
npm run start
node index.js
nodemon start
nodemon index.js
Note : You can use any of them
├── index.js
├── configs
| └── db.js
├── models
| └── userModel.js
| └── flightModel.js
| └── bookingModel.js
├── routes
| └── userRoute.js
| └── flightRoute.js
| └── bookingRoute.js
├── middlewares
| └── authenticationMiddleware.js
├──controllers
| └── userController.js
| └── flightController.js
| └── bookingController.js
Note:
- Before doing anything first create
.env
file and putPORT
,MONGO_URL
,NORMAL_KEY
. PORT
is for listening the server.MONGO_URL
is for running database and store your data in database so put your mongo link.NORMAL_KEY
is for authentication jsonwebtoken so basically this is your secret key .
{
_id: ObjectId,
airline: String,
flightNo: String,
departure: String,
arrival: String,
departureTime: Date,
arrivalTime: Date,
seats: Number,
price: Number
}
{
_id: ObjectId,
airline: String,
flightNo: String,
departure: String,
arrival: String,
departureTime: Date,
arrivalTime: Date,
seats: Number,
price: Number
}
{
_id: ObjectId,
user : { type: ObjectId, ref: 'User' },
flight : { type: ObjectId, ref: 'Flight' }
}
{
_id: ObjectId,
user : { type: ObjectId, ref: 'User' },
flight : { type: ObjectId, ref: 'Flight' }
}
METHOD | ENDPOINT | DESCRIPTION | STATUS CODE |
---|---|---|---|
POST | /api/register | This endpoint should allow users to register. | 201 |
POST | /api/login | This endpoint should allow users to login. | 201 |
GET | /api/flights | This endpoint should return a list of all available flights. | 200 |
GET | /api/flights/:id | This endpoint should return the details of a specific flight identified by its ID. | 200 |
POST | /api/flights | This endpoint should allow users to add new flights to the system. | 201 |
PUT / PATCH | /api/flights/:id | This endpoint should allow users to update the details of a specific flight identified by its ID. | 204 |
DELETE | /api/flights/:id | This endpoint should allow users to delete a specific flight identified by its ID. | 202 |
POST | /api/booking | This endpoint should allow the user to book flights. | 201 |
GET | /api/dashboard | This point should list all the bookings so far with the user and flight details. | 200 |