A hotel booking app built react and node fullstack app using Next.js on React as the frontend, users can book rooms and pay with their credit cards, manage their bookings, download booking details as pdf and much more.
Make sure the right content type like Content-Type: application/json; charset=utf-8
is correctly returned.
{
"user": {
"name": "Borguuh",
"email": "[email protected]",
"token": "jwt.token.here",
"image": "https://static.productionready.io/images/smiley-cyrus.jpg",
}
}
{
"user": {
"name": "jake",
"email": "[email protected]",
"avater": {
"url": "https://static.productionready.io/images/smiley-cyrus.jpg",
"public_id": "u1"
},
"role": "user"
}
}
{
"name": "Charming Studio < 10 Miles to Wells' Beaches!",
"pricePerNight": 168,
"description": "A friendly atmosphere and natural delights await your visit to the town of Wells! Stay at this well-equipped 1-bath studio and enjoy easy access to several beaches, including Wells Beach and Drakes Island Beach, as well as Rachel Carson National Wildlife Refuge - the best spot for wildlife viewing just 8 miles away. Not to mention, with the downtown area just 10 minutes from the vacation rental,",
"address": "4667 Bicetown Street, New York, NY, 10004",
"guestCapacity": 1,
"numOfBeds": 1,
"internet": true,
"breakfast": true,
"airConditioned": false,
"petsAllowed": false,
"roomCleaning": true,
"images": [
{
"public_id": "bookit/rooms/1_bzynlv",
"url": "https://res.cloudinary.com/bookit/image/upload/v1618590762/bookit/rooms/1_bzynlv.jpg"
},
{
"public_id": "bookit/rooms/2_s1u52n",
"url": "https://res.cloudinary.com/bookit/image/upload/v1618590761/bookit/rooms/2_s1u52n.jpg"
}
],
"category": "King"
}
If a request fails any validations, expect a 422 and errors in the following format:
{
"errors":{
"body": [
"can't be empty"
]
}
}
401 for Unauthorized requests, when a request requires authentication but it isn't provided
403 for Forbidden requests, when a request may be valid but the user doesn't have permissions to perform the action
404 for Not found requests, when a resource can't be found to fulfill the request
GET /api/admin/users
Admin level authentication required, returns a list of all users
GET /api/admin/users/:id
Admin level authentication required, returns a specific user
PATCH /api/admin/users/:id
Example request body:
{
"user":{
"name": "Jacob",
}
}
POST /api/users/login
Example request body:
{
"user":{
"email": "[email protected]",
"password": "jakejake"
}
}
No authentication required, returns a User
Required fields: email
, password
POST /api/auth/register
Example request body:
{
"user":{
"name": "Jacob",
"email": "[email protected]",
"password": "jakejake",
"avatar": {
"public_id": "result.public_id",
"url": "result.secure_url"
}
}
}
POST /api/password/forgot
Example request body:
{
"user":{
"email": "[email protected]"
}
}
No authentication required
Required fields: email
####Reset password
POST /api/password/reset/:token
Example request body:
{
"user":{
"password": "abcdef",
"new_password": "abcdef"
}
}
No authentication required
GET /api/me
Authentication required, returns current user
PUT /api/me/update
Example request body:
{
"user": {
"name": "Jacob"
}
}
Authentication required, returns a User
Required fields: email
, username
DELETE /api/admin/users/:id
Admin level authentication required
POST /api/rooms
Example request body:
{
"name": "Charming Studio < 10 Miles to Wells' Beaches!",
"pricePerNight": 168,
"description": "A friendly atmosphere and natural delights await your visit to the town of Wells! Stay at this well-equipped 1-bath studio and enjoy easy access to several beaches, including Wells Beach and Drakes Island Beach, as well as Rachel Carson National Wildlife Refuge - the best spot for wildlife viewing just 8 miles away. Not to mention, with the downtown area just 10 minutes from the vacation rental,",
"address": "4667 Bicetown Street, New York, NY, 10004",
"guestCapacity": 1,
"numOfBeds": 1,
"internet": true,
"breakfast": true,
"airConditioned": false,
"petsAllowed": false,
"roomCleaning": true,
"images": [
{
"public_id": "bookit/rooms/1_bzynlv",
"url": "https://res.cloudinary.com/bookit/image/upload/v1618590762/bookit/rooms/1_bzynlv.jpg"
},
{
"public_id": "bookit/rooms/2_s1u52n",
"url": "https://res.cloudinary.com/bookit/image/upload/v1618590761/bookit/rooms/2_s1u52n.jpg"
}
],
"category": "King"
}
Admin level authentication required, will return room
Required fields: all
GET /api/rooms/:id
No authentication required, returns a specified room
PUT /api/rooms/:id
Example request body:
{
"name": "Charming Studio < 10 Miles to Wells' Beaches!"
}
Admin level authentication required, returns a User
PUT /api/reviews
Example request body:
{
"user": "u1",
"name": "Jacob",
"rating": 5,
"comment": "good room"
}
Authentication required, returns a User
DELETE /api/rooms/:id
Admin level authentication required
POST /api/checkout_session/:roomId
Example request body:
{
"payment_method_types": "card",
"success_url": "localhost:3000/bookings/me",
"cancel_url": "{origin}/room/${room._id}",
"customer_email": "[email protected]",
"client_reference_id": "r1",
"metadata": {
"checkInDate": "2021-02-18",
"checkOutDate": "2021-02-20",
"daysOfStay": 3 },
"line_items": [
{
"name": "Charming Studio < 10 Miles to Wells' Beaches!",
"images": [
{
"public_id": "bookit/rooms/1_bzynlv",
"url": "https://res.cloudinary.com/bookit/image/upload/v1618590762/bookit/rooms/1_bzynlv.jpg"
},
{
"public_id": "bookit/rooms/2_s1u52n",
"url": "https://res.cloudinary.com/bookit/image/upload/v1618590761/bookit/rooms/2_s1u52n.jpg"
}
],
"amount": 100,
"currency": "usd",
"quantity": 1
}
]
}
POST /api/webhook