Skip to content

JoeZhou1025/383-Final-Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RESTful API

Overview:

Create a single page web application that monitors a person's consumption of a set of items in a diary form. The list of items being monitored and the list of authorized users will both be fixed in a database. Only the diary entries will be dynamically added to the database.

The application flow shall be as follows:

  1. User shall connect to the application/index.html.

    1. ALL html code shall be in this file

    2. all javascript shall be in a separate file.

    3. All css shall also be in a separate file

  2. User shall be prompted to authenticate.

    1. I have created user entries in the user table for each class member. All password are the same "test"

    2. Using JSON the users credentials shall be sent to the rest api to obtain a token

  3. Once properly authenticated the user shall be shown

    1. A summary of their Diary

    2. The last 20 entries of their diary

    3. A well formatted set of buttons allowing them to indicate they consumed one of the tracked items.

      • The items list is obtained from making an api call

      • upon clicking a button, a JSON call shall be made to api which will update their diary with the item and the date/time.

      • The page will then update its entries via javascript

  4. misc:

    1. you must always use prepare statements where appropriate
  5. REST API

    1. Get Token

      • Given user and password will get a token validating the user. If no user is present or the password does not match will return status will == "FAIL"

      • passwords are hashed using the php password_hash function

      • url: rest.php/v1/user

      • method: post

      • json_in:

        • user

        • password

      • json_out

        • status: "OK" or "FAIL"

        • msg:

        • token: string

      • Test:

    2. Get list of items

    3. Get Items user consumed

    4. Get Summary of Items

    5. Update Items Consumed

Database:

  • users: user table

    • pk

    • user

    • password

    • timestamp

  • diary: Item Entries

    • pk

    • userFK -> foreign Key to user - not the user but the pk of the user

    • itemFK -> foreign Key to item. Not the item but the PK of the item

    • timestamp

  • diaryItems: list of items

    • pk: int

    • item: tinytext

  • tokens

    • pk

    • use - actual user string

    • token - token string created randomly

    • timestamp

You must use a php based datamodel file separate from your rest code.

About

RESTful API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors