Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/anandhupa1/evaluation14-08-monday
EvaluationDepoyment
https://github.com/anandhupa1/evaluation14-08-monday
expressjs mongodb-atlas mongoose nodejs-server
Last synced: 28 days ago
JSON representation
EvaluationDepoyment
- Host: GitHub
- URL: https://github.com/anandhupa1/evaluation14-08-monday
- Owner: Anandhupa1
- Created: 2023-08-14T09:45:07.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-08-14T13:38:14.000Z (about 1 year ago)
- Last Synced: 2024-05-18T03:48:59.986Z (6 months ago)
- Topics: expressjs, mongodb-atlas, mongoose, nodejs-server
- Language: JavaScript
- Homepage: https://glamorous-blue-tank-top.cyclic.app/
- Size: 44.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Evaluation14-08-Monday
# to run this app locally you need to use your Mongodb atlas connection link with key 'mongoUrl' in .env file.
## /api/register
this route is designed to handle registrationof users
Schema
``{
name : {type:String,required:true},
email : {type:String,required:true},
password : {type:String,required:true},
}
``
response : 201 - registration successfull
if you gorgot to put any of the required fields it will give you an error message with status code 422
eg : {message : "please enter your email address"}
## api/login
you need to provide registered email and password in the request body to login
`{email: "[email protected], password:"12345"}`response : 201 - {message : "Hi anandhu , login successfull", token:"asdfsadfsadfsdf"}
``you need to store token in the headers with key token``
## POST /api/flights
To create a new flight use the following dummy data as reference
``
{
"airline": "one airlines",
"flightNo": "1",
"departure": "111",
"arrival": "111",
"departureTime": "2015-03-25",
"arrivalTime": "2015-03-26",
"seats": 100,
"price": 2000
}
``
response : 201
## GET /api/flights
To create a new flight use the following dummy data as referenceresponse : 200
``[
{
"airline": "one airlines",
"flightNo": "1",
"departure": "111",
"arrival": "111",
"departureTime": "2015-03-25",
"arrivalTime": "2015-03-26",
"seats": 100,
"price": 2000
}
]
``## GET /api/flights/:id
To create a new flight use the following dummy data as reference
response : 200
``
{
"airline": "one airlines",
"flightNo": "1",
"departure": "111",
"arrival": "111",
"departureTime": "2015-03-25",
"arrivalTime": "2015-03-26",
"seats": 100,
"price": 2000
}
``## PATCH /api/flights/:id
This endpoint allows users to update the details of a specific flight identified by its ID.
provide data need to be changed in the request body
``
{
"airline": "one airlines",
"flightNo": "1",
"departure": "111",
"arrival": "111",
"departureTime": "2015-03-25",
"arrivalTime": "2015-03-26",
"seats": 100,
"price": 2000
}
``
response : 204 | updated data will be returned## PATCH /api/flights/:id
This endpoint allows users to Delete the details of a specific flight identified by its ID.response : 202 | deleted data will be returned with data key.
``
{
"message": "deleted successfully ",
"data": {
"_id": "64da1b4aa76c84d6406456d9",
"airline": "one airlinses1234",
"flightNo": "2",
"departure": "111",
"arrival": "134511",
"departureTime": "2015-03-25T00:00:00.000Z",
"arrivalTime": "2015-03-26T00:00:00.000Z",
"seats": 100,
"price": 2000,
"__v": 0
}
}
``
## Booking Route
# POST /api/booking
This endpoint should allow the user to book flights.
This route is protected , ie you need to have the token in headers
Also you need to provide flightId in the request body as a key
``
{
"flightId":"64da1cb8d4fc2dd8aef8d195"
}``
response : 201 successfully booked
``
{
"user": "64da0ce2574dc04e76b82ca3",
"flight": "64da1c5ec4ccb0a887a7f39d",
"_id": "64da267efc37d1125bdd9f17",
"__v": 0
}
``response :409 | error : conflict
``
{
"message": "you have already booked this flight"
}
``## GET /api/booking
user will get All bookings with flight details
response :200``
[
{
"_id": "64da267efc37d1125bdd9f17",
"user": "64da0ce2574dc04e76b82ca3",
"flight": "64da1c5ec4ccb0a887a7f39d",
"__v": 0,
"flightDetails": [
{
"_id": "64da1c5ec4ccb0a887a7f39d",
"airline": "one airlines1",
"flightNo": "1",
"departure": "111",
"arrival": "111",
"departureTime": "2015-03-25T00:00:00.000Z",
"arrivalTime": "2015-03-26T00:00:00.000Z",
"seats": 100,
"price": 2000,
"__v": 0
}
]
}]``
## GET /api/booking
admin will get All bookings with userinfo and flight details
response :200``
[
{
"_id": "64da2588fc37d1125bdd9f04",
"user": "64da0ce2574dc04e76b82ca3",
"flight": "64da1cb8d4fc2dd8aef8d195",
"__v": 0,
"flightDetails": [
{
"_id": "64da1cb8d4fc2dd8aef8d195",
"airline": "one airlines1",
"flightNo": "2",
"departure": "111",
"arrival": "111",
"departureTime": "2015-03-25T00:00:00.000Z",
"arrivalTime": "2015-03-26T00:00:00.000Z",
"seats": 100,
"price": 2000,
"__v": 0
}
],
"userDetails": [
{
"_id": "64da0ce2574dc04e76b82ca3",
"name": "anandhu",
"email": "[email protected]",
"password": "$2b$10$oSYOM/NhmCvoQO6AGFtdbuFSk7XjakEshb3La7pV8ywtu1j0J2l1i",
"__v": 0
}
]
},]``