Giter Club home page Giter Club logo

restful-booker's Introduction

restful-booker

A simple Node booking form for testing RESTful web services.

Requirements

  • Docker 1.12.0
  • Docker Compose 1.8.0

Installation

  1. Ensure mongo is up and running by executing mongod in your terminal
  2. Clone the repo
  3. Navigate into the restful-booker root folder
  4. Run npm install
  5. Run npm start

Or you can run this via Docker:

  1. Clone the repo
  2. Navigate into the restful-booker root folder
  3. Run docker-compose build
  4. Run docker-compose up
  5. APIs are exposed on http://localhost:3001

API

GET /ping

Usage

GET /ping

Response

200 OK - If application is up

GET /booking

GET /booking
GET /booking?firstname=sally&lastname=brown
GET /booking?checkin=2014-03-13&checkout=2014-05-21

Parameters

  • 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

Response

[
  {
    "bookingid": 1
  },
  {
    "bookingid": 2
  },
  {
    "bookingid": 3
  },
  {
    "bookingid": 4
  }
]

GET /booking/{id}

GET /booking/1

Parameters

  • id - String - The unique identifier of the booking

Response

Accept: application/json
{
    "firstname": "Sally",
    "lastname": "Brown",
    "totalprice": 111,
    "depositpaid": true,
    "bookingdates": {
        "checkin": "2013-02-23",
        "checkout": "2014-10-23"
    },
    "additionalneeds": "Breakfast"
}
Accept: application/xml
<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

POST /booking

Payload

Content-Type: text/xml
<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>
Content-Type: application/json
{
  "firstname" : "Sally",
	"lastname" : "Brown",
	"totalprice" : 111,
	"depositpaid" : true,
	"additionalneeds" : "Breakfast",
	"bookingdates" : {
		"checkin" : "2013-02-23",
		"checkout" : "2014-10-23"
	}
}

Response

Accept: application/json
{
    "booking": {
        "firstname": "Sally",
        "lastname": "Brown",
        "totalprice": 111,
        "depositpaid": true,
        "additionalneeds": "Breakfast",
        "bookingdates": {
            "checkin": "2013-02-23",
            "checkout": "2014-10-23"
        }
    }
}
Accept: application/xml
<?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

POST /auth

Payload

{
    "username": "admin",
    "password": "password123"
}

Response

VHgTAuGPxvMsH1p

PUT /booking/{id}

PUT /booking/1

Authorisation requirements

  • Cookie: token={token received from /auth}

Parameters

  • id - String - The unique identifier of the booking

Payload

Content-Type: text/xml
<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>
Content-Type: application/json
{
  "firstname" : "Sally",
	"lastname" : "Brown",
	"totalprice" : 111,
	"depositpaid" : true,
	"additionalneeds" : "Breakfast",
	"bookingdates" : {
		"checkin" : "2013-02-23",
		"checkout" : "2014-10-23"
	}
}

Response

Accept: application/json
{
    "id": "1",
    "firstname": "Sally",
    "lastname": "Brown",
    "totalprice": 111,
    "depositpaid": true,
    "additionalneeds": "Breakfast",
    "bookingdates": {
        "checkin": "2013-02-23",
        "checkout": "2014-10-23"
    }
}
Accept: application/xml
<?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/{id}

DELETE /booking/1

Authorisation requirements

  • Cookie: token={token received from /auth}

Parameters

  • id - String - The unique identifier of the booking

Response

204 - On successful delete

restful-booker's People

Contributors

mwinteringham avatar vidhya-manojkumar avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.