willywax / NextProduct

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Next Product

Coverage Status Build Status Maintainability Reviewed by Hound

NEXTPRODUCT allows an individual or a group of individuals to vote on the product that they feel are in line with their values, so that they can decide to support

Endpoints

  1. Creating an account: POST request
/auth/signup

Body :

{
  "firstName": "Jane",
  "lastName": "Doe",
  "email": "janedoe@example.com",
  "password": "pass1234"
}

Response:

{
  "status": 201,
  "message": "Account successfully created!",
  "data": {
    "token": "43hgjg2u5gyg5ft4f5yg5u24g54.24h5f24k5y425.52h45fj245",
    "firstName": "Jane",
    "lastName": "Doe",
    "email": "janedoe@example.com"
  }
}
  1. Logging In: POST request
/auth/signin

Body :

{
  "email": "janedoe@example.com",
  "password": "pass1234"
}

Response:

{
  "status": 200,
  "message": "Successfully logged in!",
  "data": {
    "token": "43hgjg2u5gyg5ft4f5yg5u24g54.24h5f24k5y425.52h45fj245",
    "firstName": "Jane",
    "lastName": "Doe",
    "email": "janedoe@example.com"
  }
}
  1. Posting a Product: POST request
/products

Body:

{
  "name": "NextProduct",
  "description": "NEXTPRODUCT allows an individual or a group of individuals to vote on the product that they feel are in line with their values, so that they can decide to support"
}

You can also optionally upload an image.

Response:

{
  "status": 201,
  "message": "Product successfully added",
  "data": {
    "id": 324,
    "name": "NextProduct",
    "description": "NEXTPRODUCT allows an individual or a group of individuals to vote on the product that they feel are in line with their values, so that they can decide to support",
    "votes": 0,
    "image": "https://res.cloudinary.com/drayzii/image/upload/v1565290420/fssr8ssftpgqqg6p2d7k.png",
    "createdAt": "2019-08-16 21:58:12.578 +00:00",
    "updatedAt": "2019-08-17 21:58:12.578 +00:00"
  }
}
  1. Updating a Product: PATCH request
/products/:id

Body:

{
  "name": "NextProduct",
  "description": "NEXTPRODUCT allows an individual or a group of individuals to vote on the product that they feel are in line with their values, so that they can decide to support"
}

You can also update the image.

Response:

{
  "status": 200,
  "message": "Product successfully updated",
  "data": {
    "id": 324,
    "name": "NextProduct",
    "description": "NEXTPRODUCT allows an individual or a group of individuals to vote on the product that they feel are in line with their values, so that they can decide to support",
    "votes": 46,
    "image": "https://res.cloudinary.com/drayzii/image/upload/v1565290420/fssr8ssftpgqqg6p2d7k.png",
    "createdAt": "2019-08-16 21:58:12.578 +00:00",
    "updatedAt": "2019-08-17 21:58:12.578 +00:00"
  }
}
  1. Deleting a Product: DELETE request
/products/:id

Response:

{
  "status": 200,
  "message": "Product Successfully deleted!"
}
  1. Viewing all my Products: GET request
/products/my - products

Response:

{
    "status": 200,
    "message":"Successfully retrieved all your products",
    "data": [{
        "id": 324,
        "name": "NextProduct",
        "description": "NEXTPRODUCT allows an individual or a group of individuals to vote on the product that they feel are in line with their values, so that they can decide to support",
        "votes": 74,
        "image": "https://res.cloudinary.com/drayzii/image/upload/v1565290420/fssr8ssftpgqqg6p2d7k.png",
        "createdAt": "2019-08-16 21:58:12.578 +00:00",
        "updatedAt": "2019-08-17 21:58:12.578 +00:00"
    },
    {
        "id": 357,
        "name": "NewProduct",
        "description": "NEXTPRODUCT allows an individual or a group of individuals to vote on the product that they feel are in line with their values, so that they can decide to support",
        "votes": 53,
        "image": "https://res.cloudinary.com/drayzii/image/upload/v1565290420/fssr8ssftpgqqg6p2d7k.png",
        "createdAt": "2019-08-16 21:58:12.578 +00:00",
        "updatedAt": "2019-08-17 21:58:12.578 +00:00"
    }...]
}
  1. Viewing all Products: GET request
/products

Response:

{
    "status": 200,
    "message":"Successfully retrieved all products",
    "data": [{
        "id": 324,
        "name": "NextProduct",
        "description": "NEXTPRODUCT allows an individual or a group of individuals to vote on the product that they feel are in line with their values, so that they can decide to support",
        "votes": 85,
        "image": "https://res.cloudinary.com/drayzii/image/upload/v1565290420/fssr8ssftpgqqg6p2d7k.png",
        "createdAt": "2019-08-16 21:58:12.578 +00:00",
        "updatedAt": "2019-08-17 21:58:12.578 +00:00"
    },
    {
        "id": 357,
        "name": "NewProduct",
        "description": "NEXTPRODUCT allows an individual or a group of individuals to vote on the product that they feel are in line with their values, so that they can decide to support",
        "votes": 64,
        "image": "https://res.cloudinary.com/drayzii/image/upload/v1565290420/fssr8ssftpgqqg6p2d7k.png",
        "createdAt": "2019-08-16 21:58:12.578 +00:00",
        "updatedAt": "2019-08-17 21:58:12.578 +00:00"
    }...]
}
  1. Viewing a Product: GET request
/products/:id

Response:

{
  "status": 200,
  "message": "Successfully retrieved the product",
  "data": {
    "id": 324,
    "name": "NextProduct",
    "description": "NEXTPRODUCT allows an individual or a group of individuals to vote on the product that they feel are in line with their values, so that they can decide to support",
    "votes": 64,
    "image": "https://res.cloudinary.com/drayzii/image/upload/v1565290420/fssr8ssftpgqqg6p2d7k.png",
    "createdAt": "2019-08-16 21:58:12.578 +00:00",
    "updatedAt": "2019-08-17 21:58:12.578 +00:00"
  }
}
  1. Upvoting a Product: PATCH request
/products/:id/upvote

Response:

{
  "status": 200,
  "message": "Successfully upvoted the product",
  "data": {
    "id": 324,
    "name": "NextProduct",
    "description": "NEXTPRODUCT allows an individual or a group of individuals to vote on the product that they feel are in line with their values, so that they can decide to support",
    "votes": 52,
    "image": "https://res.cloudinary.com/drayzii/image/upload/v1565290420/fssr8ssftpgqqg6p2d7k.png",
    "createdAt": "2019-08-16 21:58:12.578 +00:00",
    "updatedAt": "2019-08-17 21:58:12.578 +00:00"
  }
}
  1. Removing your upvote from a product: PATCH request
/products/:id/removeUpvote

Response:

{
  "status": 200,
  "message": "Successfully removed the upvote",
  "data": {
    "id": 324,
    "name": "NextProduct",
    "description": "NEXTPRODUCT allows an individual or a group of individuals to vote on the product that they feel are in line with their values, so that they can decide to support",
    "votes": 51,
    "image": "https://res.cloudinary.com/drayzii/image/upload/v1565290420/fssr8ssftpgqqg6p2d7k.png",
    "createdAt": "2019-08-16 21:58:12.578 +00:00",
    "updatedAt": "2019-08-17 21:58:12.578 +00:00"
  }
}
  1. Adding a Comment: POST request
/products/:id/comment

Response:

{
  "status": 201,
  "message": "Comment Successfully added",
  "data": {
     "id": 3,
      "userId": 3,
      "productId": 1,
      "comment": "Cool Kids Commnet",
      "updatedAt": "2019-08-23T13:00:14.185Z",
      "createdAt": "2019-08-23T13:00:14.185Z"
  }
}

## Contributors

- Bahati Robben
- William Vedastus
- Jonathan Aurugai
- Jonathan jsonyaka
- Davis Kabiswa

About


Languages

Language:JavaScript 38.5%Language:CSS 37.2%Language:HTML 24.3%