Skip to content

Sunioatm/RoomReservation-API_Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Internship assignment

For vonder internship assignment To show about backend API project by using expressjs

Run in local

    npm install
    npm run server

User API

POST /register

Request Body

{
    "username" : "tester",
    "email" : "[email protected]",
    "password" : "123456"
}

Response

Status 201 Created
{
    "username": "tester",
    "email": "[email protected]",
    "password": "$2a$10$4V0HYFuASQrgW2cJJ7iwa.Ua3Hzp94.cLu89WdjmsQ0IMGYvwTmfy",
    "_id": "6481cfb04d3ea04bde19684d",
    "__v": 0
}

POST /login

Request Body

{
    "identifier":"tester",
    "password":"123456"
}

Response

Status 200 OK
{
    "_id": "6481772bcc1c8fc63823ce76",
    "username": "tester",
    "email": "[email protected]",
    "password": "$2a$10$Huah7JSxQQup3q1We4dk8u.BpD2YBgP0mBaJlMdewwSXmqIgX8032",
    "__v": 0,
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiNjQ4MTc3MmJjYzFjOGZjNjM4MjNjZTc2IiwiZW1haWwiOiJ0ZXN0ZXJAZW1haWwuY29tIiwiaWF0IjoxNjg2MjI5MjIzLCJleHAiOjE2ODYyMzY0MjN9.sNPzhDbfzNy2vLG3YDZ5k9EUDIXKbaZpsAXqNT1Z9rc"
}

Room API

POST /create

Request Body

{
    "name" : "Room7",
    "capacity" : "777"
}

Response

{
    "message": "Room Created",
    "room": {
        "name": "Room7",
        "capacity": "777",
        "_id": "64825047e06e42f8df258927",
        "reserveDateTime": [],
        "roomId": 7,
        "__v": 0
    }
}

GET /show

Response

Status 200 OK
[
    {
        "_id": "648234abf72614d317ec48d3",
        "name": "Room1",
        "capacity": "15",
        "reserveDateTime": [
            {
                "start": "2023-06-09T03:00:00.000Z",
                "end": "2023-06-09T04:00:00.000Z",
                "_id": "64824511001bfe27241377e6"
            },
            {
                "start": "2023-06-09T05:00:00.000Z",
                "end": "2023-06-09T06:00:00.000Z",
                "_id": "6482451d001bfe27241377ea"
            }
        ],
        "roomId": 1,
        "__v": 43
    }, ...
]

GET /:id

Resposne

Status 200 OK
{
    "_id": "648234abf72614d317ec48d3",
    "name": "Room1",
    "capacity": "15",
    "reserveDateTime": [
        {
            "start": "2023-06-09T03:00:00.000Z",
            "end": "2023-06-09T04:00:00.000Z",
            "_id": "64824511001bfe27241377e6"
        },
        {
            "start": "2023-06-09T05:00:00.000Z",
            "end": "2023-06-09T06:00:00.000Z",
            "_id": "6482451d001bfe27241377ea"
        }
    ],
    "roomId": 1,
    "__v": 43
}

GET /name/:name

Response

Status 200 OK
{
    "_id": "648234abf72614d317ec48d3",
    "name": "Room1",
    "capacity": "15",
    "reserveDateTime": [
        {
            "start": "2023-06-09T03:00:00.000Z",
            "end": "2023-06-09T04:00:00.000Z",
            "_id": "64824511001bfe27241377e6"
        },
        {
            "start": "2023-06-09T05:00:00.000Z",
            "end": "2023-06-09T06:00:00.000Z",
            "_id": "6482451d001bfe27241377ea"
        }
    ],
    "roomId": 1,
    "__v": 43
}

POST /check

Request Body

{
    "identifier" : "1",
    "start" : "08/06/23 20:00",
    "end" : "08/06/23 21:00"
}

Response

Status 200 Ok
This room is available during the specified time.

POST /reserve

Request Body

{
    "identifier" : "7",
    "start" : "09/06/23 11:00",
    "end" : "09/06/23 12:00"
}

Response

Status 200 Ok
{
    "_id": "64825047e06e42f8df258927",
    "name": "Room7",
    "capacity": "777",
    "reserveDateTime": [
        {
            "start": "2023-06-09T04:00:00.000Z",
            "end": "2023-06-09T05:00:00.000Z",
            "_id": "64825162e06e42f8df258972"
        }
    ],
    "roomId": 7,
    "__v": 1
}

POST /cancel

Request Body

{
    "identifier" : "7",
    "start" : "09/06/23 11:00"
}

Resposne

Status 200 OK
{
    "message": "Cancel successfully",
    "room": {
        "_id": "64825047e06e42f8df258927",
        "name": "Room7",
        "capacity": "777",
        "reserveDateTime": [],
        "roomId": 7,
        "__v": 2
    }
}

Releases

No releases published

Packages

No packages published