A simple Node booking form for testing RESTful web services.
- Docker 17.09.0
- Docker Compose 1.16.1
- Ensure mongo is up and running by executing
mongod
in your terminal - Clone the repo
- Navigate into the restful-booker root folder
- Run
npm install
- Run
npm start
Or you can run this via Docker:
- Clone the repo
- Navigate into the restful-booker root folder
- Run
docker-compose build
- Run
docker-compose up
- APIs are exposed on http://localhost:3001
- GET /ping
- GET /booking
- GET /booking/{id}
- POST /booking
- POST /auth
- PUT /booking/{id}
- DELETE /booking/{id}
GET /ping
200 OK - If application is up
GET /booking
GET /booking?firstname=sally&lastname=brown
GET /booking?checkin=2014-03-13&checkout=2014-05-21
- firstname - String - The firstname of the user
- lastname - String - The lastname of the user
- checkin - Date(CCYY-MM-DD) - The day in which person(s) checks in
- checkout - Date(CCYY-MM-DD) - The day in which person(s) checks out
[
{
"bookingid": 1
},
{
"bookingid": 2
},
{
"bookingid": 3
},
{
"bookingid": 4
}
]
GET /booking/1
- id - String - The unique identifier of the booking
{
"firstname": "Sally",
"lastname": "Brown",
"totalprice": 111,
"depositpaid": true,
"bookingdates": {
"checkin": "2013-02-23",
"checkout": "2014-10-23"
},
"additionalneeds": "Breakfast"
}
<booking>
<firstname>Sally</firstname>
<lastname>Brown</lastname>
<totalprice>111</totalprice>
<depositpaid>true</depositpaid>
<bookingdates>
<checkin>2013-02-23</checkin>
<checkout>2014-10-23</checkout>
</bookingdates>
<additionalneeds>Breakfast</additionalneeds>
</booking>
POST /booking
<booking>
<firstname>Sally</firstname>
<lastname>Brown</lastname>
<totalprice>111</totalprice>
<depositpaid>true</depositpaid>
<additionalneeds>Breakfast</additionalneeds>
<bookingdates>
<checkin>2013/02/23</checkin>
<checkout>2014/10/23</checkout>
</bookingdates>
</booking>
{
"firstname" : "Sally",
"lastname" : "Brown",
"totalprice" : 111,
"depositpaid" : true,
"additionalneeds" : "Breakfast",
"bookingdates" : {
"checkin" : "2013-02-23",
"checkout" : "2014-10-23"
}
}
{
"booking": {
"firstname": "Sally",
"lastname": "Brown",
"totalprice": 111,
"depositpaid": true,
"additionalneeds": "Breakfast",
"bookingdates": {
"checkin": "2013-02-23",
"checkout": "2014-10-23"
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<created-booking>
<booking>
<firstname>Sally</firstname>
<lastname>Brown</lastname>
<totalprice>111</totalprice>
<depositpaid>true</depositpaid>
<additionalneeds>Breakfast</additionalneeds>
<bookingdates>
<checkin>2013-02-23</checkin>
<checkout>2014-10-23</checkout>
</bookingdates>
</booking>
</created-booking>
POST /auth
{
"username": "admin",
"password": "password123"
}
{"token":"4435e80661e070c"}
PUT /booking/1
- Cookie: token={token received from /auth}
- id - String - The unique identifier of the booking
<booking>
<firstname>Sally</firstname>
<lastname>Brown</lastname>
<totalprice>111</totalprice>
<depositpaid>true</depositpaid>
<additionalneeds>Breakfast</additionalneeds>
<bookingdates>
<checkin>2013/02/23</checkin>
<checkout>2014/10/23</checkout>
</bookingdates>
</booking>
{
"firstname" : "Sally",
"lastname" : "Brown",
"totalprice" : 111,
"depositpaid" : true,
"additionalneeds" : "Breakfast",
"bookingdates" : {
"checkin" : "2013-02-23",
"checkout" : "2014-10-23"
}
}
{
"id": "1",
"firstname": "Sally",
"lastname": "Brown",
"totalprice": 111,
"depositpaid": true,
"additionalneeds": "Breakfast",
"bookingdates": {
"checkin": "2013-02-23",
"checkout": "2014-10-23"
}
}
<?xml version="1.0" encoding="UTF-8"?>
<booking>
<id>1</id>
<firstname>Sally</firstname>
<lastname>Brown</lastname>
<totalprice>111</totalprice>
<depositpaid>true</depositpaid>
<additionalneeds>Breakfast</additionalneeds>
<bookingdates>
<checkin>2013-02-23</checkin>
<checkout>2014-10-23</checkout>
</bookingdates>
</booking>
DELETE /booking/1
- Cookie: token={token received from /auth}
- id - String - The unique identifier of the booking
204 - On successful delete