Skip to content

UseMyTechStuffBuildWeek/UseMyTechStuffBackend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

85 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Use My Tech App

POST - Create Account

create a user with role type of renter or owner

https://use-my-tech-app.herokuapp.com/api/auth/register
what you need:
{
    "username": "marco",  
    "password": "foobar", 
    "role": "owner"
}

what you get back:
{
    "user_id": 12,
    "username": "mary",
    "password": "$2a$08$cHlS2uqmuiHGvZcqcnFKNOnWcHJD49nDpINZslFqKaQi8dWMIoclC",
    "role": "owner"
}

POST - Login

https://use-my-tech-app.herokuapp.com/api/auth/login
what you need:
role can be owner or renter
{
    "username": "marco",  
    "password": "foobar",
}

what you get back:
{
    "message": "marco is back!",
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWJqZWN0IjoxMCwidXNlcm5hbWUiOiJtYXJjbyIsInJvbGUiOiJvd25lciIsImlhdCI6MTYxOTM2ODY1OCwiZXhwIjoxNjE5NDU1MDU4fQ.Hl9vOkOOhNPTcuckYaoj1b8KCMUvCHXGgMPFK4Vd2XA",
    "role": "owner"
}

DELETE - Logout User

https://use-my-tech-app.herokuapp.com/api/auth/logout
Status: 200 OK

GET - Get All Equipment

https://use-my-tech-app.herokuapp.com/api/equipment
Returns ALL equipment. Anyone can make this call.

what you get back:
[
    {
        "owner": {
            "id": 2,
            "username": "Mario"
        },
        "id": 1,
        "name": "camera",
        "imgUrl": "https://images.unsplash.com/photo-1516035069371-29a1b244cc32?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=1000&q=80",
        "description": "like new",
        "isAvailable": true
    },
    {
        "owner": {
            "id": 2,
            "username": "Mario"
        },
        "id": 2,
        "name": "video camera",
        "imgUrl": "https://images.unsplash.com/photo-1589872307379-0ffdf9829123?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1051&q=80",
        "description": "excellent audio and image",
        "isAvailable": true
    },
    {
        "owner": {
            "id": 2,
            "username": "Mario"
        },
        "id": 3,
        "name": "podcast microphone",
        "imgUrl": "https://images.unsplash.com/photo-1590602847861-f357a9332bbc?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=634&q=80",
        "description": "best audio out there",
        "isAvailable": true
    }
]

GET - Get Equipment By Id

https://use-my-tech-app.herokuapp.com/api/equipment/:equipment_id
Returns equipment with specific id. Anyone can make this call.

what you get back:
{
    "owner": {
        "id": 2
    },
    "id": 1,
    "name": "camera",
    "imgUrl": "https://images.unsplash.com/photo-1516035069371-29a1b244cc32?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=1000&q=80",
    "description": "like new",
    "isAvailable": true
}

GET - Get Owned Equipment

https://use-my-tech-app.herokuapp.com/api/users/owner
Returns owned equipment. Only owners can make this call.

what you get back:
[
    {
        "equipment_id": 1,
        "equipment_name": "camera",
        "equipment_description": "like new",
        "equipment_img": "https://images.unsplash.com/photo-1516035069371-29a1b244cc32?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=1000&q=80",
        "equipment_available": true
    },
    {
        "equipment_id": 2,
        "equipment_name": "video camera",
        "equipment_description": "excellent audio and image",
        "equipment_img": "https://images.unsplash.com/photo-1589872307379-0ffdf9829123?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1051&q=80",
        "equipment_available": false
    },
    {
        "equipment_id": 3,
        "equipment_name": "podcast microphone",
        "equipment_description": "best audio out there",
        "equipment_img": "https://images.unsplash.com/photo-1590602847861-f357a9332bbc?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=634&q=80",
        "equipment_available": false
    }
]

GET - Get Rented Equipment

https://use-my-tech-app.herokuapp.com/api/users/renter
Returns rented equipment. Only renters can make this call.

what you get back:
[
    {
        "owner": {
            "id": 2,
            "username": "Mario"
        },
        "id": 3,
        "name": "podcast microphone",
        "imgUrl": "https://images.unsplash.com/photo-1590602847861-f357a9332bbc?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=634&q=80",
        "description": "best audio out there",
        "isAvailable": false
    },
    {
        "owner": {
            "id": 2,
            "username": "Mario"
        },
        "id": 2,
        "name": "video camera",
        "imgUrl": "https://images.unsplash.com/photo-1589872307379-0ffdf9829123?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1051&q=80",
        "description": "excellent audio and image",
        "isAvailable": false
    }
]

POST - Add Equipment

https://use-my-tech-app.herokuapp.com/api/equipment
Adds equipment to database. Only owners can make this call.

what you need:
{
    "name": "mining rig",
    "description": "generates money",
    "imgUrl": "https://cdn.mos.cms.futurecdn.net/pLmxqBBToop8EyqSyTzExn-970-80.jpg.webp"
}

what you get back:
{
    "owner": {
        "id": 2,
        "username": "Mario"
    },
    "id": 4,
    "name": "mining rig",
    "imgUrl": "insert-image-url-here",
    "description": "generates money",
    "isAvailable": true
}

PUT - Update Equipment By ID

https://use-my-tech-app.herokuapp.com/api/equipment/:equipment_id
Updates existing owned equipment. Only owner of equipment can make this call.

what you need (optional):
{
    "name": "mining rig",
    "description": "generates money",
    "imgUrl": "https://cdn.mos.cms.futurecdn.net/pLmxqBBToop8EyqSyTzExn-970-80.jpg.webp"
}

what you get back:
{
    "owner": {
        "id": 2,
        "username": "Mario"
    },
    "id": 4,
    "name": "mining rig",
    "imgUrl": "insert-image-url-here",
    "description": "generates money",
    "isAvailable": true
}

DELETE - Remove Equipment By ID

https://use-my-tech-app.herokuapp.com/api/equipment/:equipment_id
Deletes equipment with specific id. Only owner of equipment can make this call.

what you get back:
{
    "owner": {
        "id": 2,
        "username": "Mario"
    },
    "id": 4,
    "name": "mining rig",
    "imgUrl": "insert-image-url-here",
    "description": "generates money",
    "isAvailable": true
}

POST - Create A Rental Request

https://use-my-tech-app.herokuapp.com/api/requests
Creates a request to rent equipment. Only renters can make this call.

what you need:
{
    "equipment_id": 2
}

what you get back:
{
    "request_id": 4,
    "user_id": 1,
    "equipment_id": 2,
    "accepted": false
}

PUT - Accept Rental Request By ID

https://use-my-tech-app.herokuapp.com/api/requests/:request_id
Accepts request to rent equipment. Makes equipment unavailable until
rental is terminated. Only owner of equipment can make this call.

what you get back:
{
    "request_id": 4,
    "user_id": 1,
    "equipment_id": 2,
    "accepted": false
}

DELETE - Terminate Rental Request By ID

https://use-my-tech-app.herokuapp.com/api/requests/:request_id
Accepts request to rent equipment. Makes equipment unavailable until
rental is terminated. Only owner of equipment can make this call.

what you get back:
{
    "request_id": 4,
    "user_id": 1,
    "equipment_id": 2,
    "accepted": false
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published