Skip to content

hmartos/angular-reservation-api

Repository files navigation

angular-reservation REST API

This project is a REST API implementation example for angular-reservation module. This is only an example with NodeJS and Express and may need some protection since there is no Authentication nor Authorization control.

Requirements

  • NodeJS and npm
  • MongoDB

Installation

  • Clone the repo: git clone https://github.com/hmartos/angular-reservation-api.git
  • Install dependencies: npm install
  • Start the server: node server.js There is a preconfifigured start script so you can run npm start instead

Database initialization

There is a Python script to initialize database with a schedule for 10 years. Edit start date, end date and time slots in the script and execute

cd app
pip install timedelta pymongo json date
python fillDb.py

REST API Specification

Get available hours for selected date

Called on select date, return the list of available hours for selected date.

  • URL /availableHours

  • Method: GET

  • URL Params

    • Required: selectedDate=[string]
  • Success Response: Returns an array with available hours for selected date, a SUCCESS status and a message.
    You can use status to return a 200 code response with an error and an optional message to explain what has happened.

    • Code: 200
      Content:
{
	"availableHours": [
	  "10:00",
	  "10.30",
	  "11.30",
	  "12.30",
	  "13.00",
	  "17.00",
	  "17.30",
	  "18.00",
	  "18.30",
	  "19.00"
	],
	"status": "SUCCESS",
	"message": ""
}

Reserve hour for selected date

Called on reserve action. Reserve selected hour from list of available hours for selected date passing user data.

  • URL /reserve

  • Method: POST

  • Data Params Include selected date, selected data and user data.

{
	"selectedDate": "2017-03-25",
	"selectedHour": "10:00",
	"userData": {
		"name": "Héctor",
		"phone": "123456789",
		"email": "hector@email.com"
	}
}
  • Success Response: Returns a SUCCESS status and a message.
    You can use status to return a 200 code response with an error and an optional message to explain what has happened.

    • Code: 200
      Content:
{
  "status": "SUCCESS",
  "message": ""
}

Testing the API

Test your API using exported Postman collection and environment executing npm test

About

Simple Express REST API implementation for angular-reservation module

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published