10000 GitHub - tygedavis/Backend
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

tygedavis/Backend

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Backend - Use my Tech

Documentation

Section Contents:

Dummy data

Users

[
  {id: 1, username: 'test', password:'123', department:'owner'},
  {id: 2, username: 'db', password:'123', department:'owner'}

]

Items

[
      { id: 1, 
        item_name:'Roomba', 
        description:'Does the cleaning for you',
        user_id: 2,
        availability: true,
        daily_rate: 20,
        condition: "Great",
        location: 'LA'
      },
      { id: 2, 
        item_name:'XXL Megaphone', 
        description:'Obnoxiously loud ',
        user_id: 1,
        availability: true,
        daily_rate: 15,
        condition: "It works",
        location: 'LA'
      }
]

Endpoints

Register

/api/register POST

Expects an object with this format as the request body:

{
  "username": "user1",   //string (required)
  "password": "password", //string (required)
  "department": "owner or renter" //string (required)
}

Login

/api/login POST

Expects an object with this correct credentials stored in the APi:

{
  "username": "db",   //string (required)
  "password": "123", //string (required)

}

All Items

Authorization needed, 'token'

/api/items GET

Will return all items in the database and their information, looking something like this...

[
    {
        "id": 1,
        "item_name": "Roomba",
        "description": "Does the cleaning for you",
        "user_id": 2,
        "availability": 1,
        "daily_rate": 20,
        "condition": "Great",
        "location": "LA"
    }
]


Single Item

Authorization needed, 'token'

/api/item/:id GET

Note-':id' will be replaced by items id number

Will return a single item based off of provided id

Add item

Auth needed

/api/item POST

Example of data needed:

Will add an item to the database

        "item_name": "3D Printer", //string
        "description": "it's 3D", //string
        "user_id": 3, //integer
        "availability": 1, //boolean
        "daily_rate": 75, //integer
        "condition": "Not a Scratch", //string
        "location": "AZ" //string,
        "imgs":"" //string

Delete item

Auth needed

/api/item/:id DELETE

Note-':id' will be replaced by items id number

Will delete the user from the database

Add item by Owner

Auth needed

/api/users/:id/items POST

Used to create an item, assigned to user_id

Example of data that can be inputed:

        "item_name": "3D Printer", //string required
        "description": "it's 3D", //string  required
        "availability": 1, //boolean 
        "daily_rate": 75, //integer
        "condition": "Not a Scratch", //string required
        "location": "AZ" //string required
        "imgs": "" //string

Get items by User

Auth needed

/api/users/:id/items GET

Used to get all items assigned to specific owner

Get User by ID

Auth needed

/api/user/:id GET

Gets the user by ID and it's credentials

Delete User by ID

Auth needed

/api/user/:id DELETE

Deletes user by ID

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%
0