Skip to content

Valtjoker/p2-iproject-server

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

p2-iproject-server

Individual Project - Server

List of Available Endpoints:

  • GET /pets
  • GET /pets/id
  • GET /types
  • GET /rents
  • GET /rents/recent
  • GET /reviews
  • POST /pets/id
  • PUT /rents/:id
  • POST /users/register
  • POST /users/login
  • POST /users/google-login

GET /pets

Description

  • get all pets data

response

200 - OK

  • Body
{
    "animals": [
        {
            "id": 52506866,
            "organization_id": "NJ927",
            "url": "https://www.petfinder.com/cat/jimma-52506866/nj/toms-river/all-fur-one-pet-rescue-and-adoptions-inc-nj927/?referrer_id=08c1583b-3ed9-4941-8f88-1ca738c30f43",
            "type": "Cat",
            "species": "Cat",
            "breeds": {
                "primary": "Domestic Short Hair",
                "secondary": null,
                "mixed": false,
                "unknown": false
            },
            "colors": {
                "primary": "Black & White / Tuxedo",
                "secondary": null,
                "tertiary": null
            },
            "age": "Young",
            "gender": "Female",
            "size": "Small",
            "coat": null,
            "attributes": {
                "spayed_neutered": false,
                "house_trained": false,
                "declawed": false,
                "special_needs": false,
                "shots_current": false
            },
            "environment": {
                "children": true,
                "dogs": null,
                "cats": true
            },
            "tags": [
                "Social and Friendly"
            ],
            "name": "Jimma",
            "description": "The ultimate momma, Jimma, is a love bug! She is a part of the Ethiopia litter with her babes. Jimma...",
            "organization_animal_id": "19436",
            "photos": [
                {
                    "small": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/52506866/1/?bust=1667975751&width=100",
                    "medium": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/52506866/1/?bust=1667975751&width=300",
                    "large": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/52506866/1/?bust=1667975751&width=600",
                    "full": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/52506866/1/?bust=1667975751"
                },
                {
                    "small": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/52506866/2/?bust=1667897730&width=100",
                    "medium": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/52506866/2/?bust=1667897730&width=300",
                    "large": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/52506866/2/?bust=1667897730&width=600",
                    "full": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/52506866/2/?bust=1667897730"
                },
                {
                    "small": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/52506866/3/?bust=1667897731&width=100",
                    "medium": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/52506866/3/?bust=1667897731&width=300",
                    "large": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/52506866/3/?bust=1667897731&width=600",
                    "full": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/52506866/3/?bust=1667897731"
                },
                {
                    "small": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/52506866/4/?bust=1667897720&width=100",
                    "medium": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/52506866/4/?bust=1667897720&width=300",
                    "large": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/52506866/4/?bust=1667897720&width=600",
                    "full": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/52506866/4/?bust=1667897720"
                },
                {
                    "small": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/52506866/5/?bust=1667897730&width=100",
                    "medium": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/52506866/5/?bust=1667897730&width=300",
                    "large": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/52506866/5/?bust=1667897730&width=600",
                    "full": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/52506866/5/?bust=1667897730"
                },
                {
                    "small": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/52506866/6/?bust=1667897729&width=100",
                    "medium": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/52506866/6/?bust=1667897729&width=300",
                    "large": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/52506866/6/?bust=1667897729&width=600",
                    "full": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/52506866/6/?bust=1667897729"
                }
            ],
            "primary_photo_cropped": {
                "small": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/52506866/1/?bust=1667975751&width=300",
                "medium": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/52506866/1/?bust=1667975751&width=450",
                "large": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/52506866/1/?bust=1667975751&width=600",
                "full": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/52506866/1/?bust=1667975751"
            },
            "videos": [],
            "status": "adoptable",
            "status_changed_at": "2021-09-29T16:05:38+0000",
            "published_at": "2021-07-29T11:09:42+0000",
            "distance": null,
            "contact": {
                "email": "[email protected]",
                "phone": "(732) 255-3871",
                "address": {
                    "address1": "1747 Hooper Avenue",
                    "address2": "Suite 11",
                    "city": "Toms River",
                    "state": "NJ",
                    "postcode": "08753",
                    "country": "US"
                }
            },
            "_links": {
                "self": {
                    "href": "/v2/animals/52506866"
                },
                "type": {
                    "href": "/v2/types/cat"
                },
                "organization": {
                    "href": "/v2/organizations/nj927"
                }
            }
        },
        ...
    ]
}

GET /pets/:id

Description

  • one pets data

response

200 - OK

  • Body
{
    "id": 58788734,
    "organization_id": "TN478",
    "url": "https://www.petfinder.com/dog/hercules-58788734/tn/chattanooga/mckamey-animal-center-tn478/?referrer_id=08c1583b-3ed9-4941-8f88-1ca738c30f43",
    "type": "Dog",
    "species": "Dog",
    "breeds": {
        "primary": "Boxer",
        "secondary": null,
        "mixed": false,
        "unknown": false
    },
    "colors": {
        "primary": "Brindle",
        "secondary": null,
        "tertiary": null
    },
    "age": "Adult",
    "gender": "Male",
    "size": "Large",
    "coat": null,
    "attributes": {
        "spayed_neutered": true,
        "house_trained": false,
        "declawed": null,
        "special_needs": false,
        "shots_current": true
    },
    "environment": {
        "children": null,
        "dogs": false,
        "cats": null
    },
    "tags": [
        "Food Motivated",
        "Leash Walk Me",
        "Loves Squeaker Toys",
        "Loves Stuffed Toys",
        "Loves Tennis Balls",
        "Seems Housetrained",
        "Shy at First",
        "Single Dog Home"
    ],
    "name": "Hercules",
    "description": null,
    "organization_animal_id": "MACT-A-100114",
    "photos": [
        {
            "small": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/58788734/1/?bust=1667878532&width=100",
            "medium": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/58788734/1/?bust=1667878532&width=300",
            "large": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/58788734/1/?bust=1667878532&width=600",
            "full": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/58788734/1/?bust=1667878532"
        },
        {
            "small": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/58788734/2/?bust=1667943932&width=100",
            "medium": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/58788734/2/?bust=1667943932&width=300",
            "large": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/58788734/2/?bust=1667943932&width=600",
            "full": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/58788734/2/?bust=1667943932"
        },
        {
            "small": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/58788734/3/?bust=1667943933&width=100",
            "medium": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/58788734/3/?bust=1667943933&width=300",
            "large": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/58788734/3/?bust=1667943933&width=600",
            "full": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/58788734/3/?bust=1667943933"
        },
        {
            "small": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/58788734/4/?bust=1667943931&width=100",
            "medium": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/58788734/4/?bust=1667943931&width=300",
            "large": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/58788734/4/?bust=1667943931&width=600",
            "full": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/58788734/4/?bust=1667943931"
        },
        {
            "small": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/58788734/5/?bust=1667943931&width=100",
            "medium": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/58788734/5/?bust=1667943931&width=300",
            "large": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/58788734/5/?bust=1667943931&width=600",
            "full": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/58788734/5/?bust=1667943931"
        }
    ],
    "primary_photo_cropped": {
        "small": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/58788734/1/?bust=1667878532&width=300",
        "medium": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/58788734/1/?bust=1667878532&width=450",
        "large": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/58788734/1/?bust=1667878532&width=600",
        "full": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/58788734/1/?bust=1667878532"
    },
    "videos": [],
    "status": "adoptable",
    "status_changed_at": "2022-11-08T03:25:22+0000",
    "published_at": "2022-11-08T03:25:22+0000",
    "distance": null,
    "contact": {
        "email": "[email protected]",
        "phone": "(423) 305-6514",
        "address": {
            "address1": "4500 N. Access Road",
            "address2": null,
            "city": "Chattanooga",
            "state": "TN",
            "postcode": "37415",
            "country": "US"
        }
    },
    "_links": {
        "self": {
            "href": "/v2/animals/58788734"
        },
        "type": {
            "href": "/v2/types/dog"
        },
        "organization": {
            "href": "/v2/organizations/tn478"
        }
    }
}

response

404 - Not found

Body

{"msg":"Pet data not found!"}

GET /types

Description

  • get all types data

response

200 - OK

  • Body
{
    "types": [
        {
            "name": "Dog",
            "coats": [
                "Hairless",
                "Short",
                "Medium",
                "Long",
                "Wire",
                "Curly"
            ],
            "colors": [
                "Apricot / Beige",
                "Bicolor",
                "Black",
                "Brindle",
                "Brown / Chocolate",
                "Golden",
                "Gray / Blue / Silver",
                "Harlequin",
                "Merle (Blue)",
                "Merle (Red)",
                "Red / Chestnut / Orange",
                "Sable",
                "Tricolor (Brown, Black, & White)",
                "White / Cream",
                "Yellow / Tan / Blond / Fawn"
            ],
            "genders": [
                "Male",
                "Female"
            ],
            "_links": {
                "self": {
                    "href": "/v2/types/dog"
                },
                "breeds": {
                    "href": "/v2/types/dog/breeds"
                }
            }
        },
        ...
    ]
}

GET /rents

Description

  • get all active rents data

request

  • headers
{"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiaWF0IjoxNjY3OTUwOTU3fQ.OdiX5FgUDEEB0dgOSCk0c7IDhz30oub73LS8hsEJVE4"}

response

200 - OK

  • Body
[
    {
        "id": 9,
        "name": "Remy ",
        "imgUrl": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/56519063/2/?bust=1659576621&width=300",
        "content": null,
        "rating": null,
        "rented": true,
        "rentEnd": null,
        "PetId": 56519063,
        "UserId": 1,
        "createdAt": "2022-11-10T04:24:18.402Z"
    }
]

GET /rents/recent

Description

  • get recent rents data

request

  • headers
{"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiaWF0IjoxNjY3OTUwOTU3fQ.OdiX5FgUDEEB0dgOSCk0c7IDhz30oub73LS8hsEJVE4"}

response

200 - OK

  • Body
[
    {
        "id": 1,
        "name": "Holly",
        "imgUrl": "https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/58797522/2/?bust=1667950195&width=300",
        "content": "lucuuukk bangeettt",
        "rating": 4,
        "rented": false,
        "rentEnd": "2022-11-08T23:49:23.566Z",
        "PetId": 58797522,
        "UserId": 1,
        "createdAt": "2022-11-08T23:46:00.048Z"
    }, ...
]

POST /pets/:id

Description

  • add pet to rent

request

  • headers
{"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiaWF0IjoxNjY3OTUwOTU3fQ.OdiX5FgUDEEB0dgOSCk0c7IDhz30oub73LS8hsEJVE4"}

response

201 - Created

  • Body
{
    "msg": "You are now renting Remy "
}

response

400 - Bad Request

Body

{"msg":"Input must be completed!"}

response

400 - Bad Request

Body

{"msg":"Data must be unique!"}

PUT /rents/:id

Description

  • stop renting and add review

request

  • headers
{"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTEsImlhdCI6MTY2NjIzODkxM30.aMQLfrvMGA56nW3amkms4DY-8-54jekjzTZtDPhBaFE"}
  • Body
{
        "rating": 4,
        "comment": "uwaw",
}

response

200 - OK

  • Body
{
    "msg": "Review posted"
}

response

403 - Forbidden

Body

{"msg":"You are forbidden to do this action!"}

response

404 - Not found

Body

{"msg":"User data not found!"}

POST /users/register

Description

  • register new user

request

  • body
{
    "username":"Cooler_asandon7","email":"[email protected]","password":"guekeren501","phoneNumber":"165-470-1250","address":"8 Manitowish Circle"
}

response

201 - Created

  • Body
{
    "msg": "Account has been created",
    "id": 14,
    "username": "Cooler_asandon7"
}

response

400 - Bad Request

Body

{"msg":"Input must be completed!"}

response

400 - Bad Request

Body

{"msg":"Data must be unique!"}

POST /users/login

Description

  • user login

request

  • body
{
    "email":"[email protected]","password":"404gaknanya"
}

response

200 - OK

  • Body
{
    "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTEsImlhdCI6MTY2NjIzODkxM30.aMQLfrvMGA56nW3amkms4DY-8-54jekjzTZtDPhBaFE",
    "email": "[email protected]",
    "username": "hahahihi",
    "role": "admin"
}

response

400 - Bad request

Body

{"msg":"Please input email and password for login"}

response

401 - Unauthorized

Body

{"msg":"Invalid email or password!"}

POST /users/google-login

Description

  • user google login

request

  • body
{
    "google_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6ImVlMWI5Zjg4Y2ZlMzE1MWRkZDI4NGE2MWJmOGNlY2Y2NTliMTMwY2YiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20iLCJuYmYiOjE2NjYyNjc0MTIsImF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VCJ9.eyJpZCI6MTQsImlhdCI6MTY2NjI2NzcxMn0.OpObCMXc1k-vT_FupbOxlzsm3VwTwN07Jb2Ov0XF5I4",
    "email": "[email protected]",
    "username": "adji ugroho",
    "role": "staff"
}

Global error

401 - Unauthorized

Body

{"msg":"Invalid access token"}

500 - Server error

Body

{"msg":"Internal server error!"}

About

Individual Project - Server

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 99.9%
  • Procfile 0.1%