Skip to content

ggsbv/testable-shoe-catalogue-api

Repository files navigation

Shoe Catalogue API

This API can be used for storing and retrieving shoe data.

Consumer Section

The RESTful API is hosted at https://shoe-catalogue-api-codex.herokuapp.com/api. Therefore, all calls to the API should be made to that base URL, after appending any of the following URIs, depending on your intentions:

Retrieving

1. Want to get all shoes currently stored in the database?

  • Request Type: GET

  • URI: /shoes

Filtering

1. Want to filter shoes based on their brand?

  • Request Type: GET

  • URI: /shoes/brand/<brand name>

  • Example:

https://shoe-catalogue-api-codex.herokuapp.com/api/shoes/brand/Nike

2. Want to filter shoes based on their size?

  • Request Type: GET

  • URI: /shoes/size/<size>

  • Example:

https://shoe-catalogue-api-codex.herokuapp.com/api/shoes/size/9

3. Want to filter shoes based on their color?

  • Request Type: GET

  • URI: /shoes/color/<color>

  • Example:

https://shoe-catalogue-api-codex.herokuapp.com/api/shoes/color/blue

4. Want to filter shoes based on a combination of properties?

  • Request Type: GET

  • URI:

The order of the URI for filtering follows the structure of instructions 1 - 3, including their
sequence. Brand has priority in terms of sequence over both size and color. Size has second priority, 
and color URI structure is always the final element in the sequence. Always brand followed by size
followed by color.
  • Example:
https://shoe-catalogue-api-codex.herokuapp.com/api/shoes/brand/Nike/size/11/color/red 

5. Want to find a shoe based on its ID?

  • Request Type: GET

  • URI: /shoes/id/<id>

  • Example:

https://shoe-catalogue-api-codex.herokuapp.com/api/shoes/id/592400e0c9c4f40004754d40

Updating stock

1. Want to add a new shoe to the database?

  • Request Type: POST

  • Data Type: JSON

  • Data Format:

A single JSON object representing a shoe.

  {
    brand : String,
    size : Integer,
    color : String,
    in_stock : Integer // number of shoes to add to the stock
    price : Integer
  }
  • URI: /shoes

  • Example:

{
  brand : 'Nike',
  size : 10,
  color : 'blue',
  in_stock : 10,
  price : 1200
}

2. Want to decrement shoe stock (after a sale, for example)?

  • Request Type: POST

  • Data Type: JSON

  • Data Format:

An array of object(s) representing shoes.

  [
    {       
      _id : String,
      qty : Integer // number of shoes sold
    },
  ];
  • URI: /shoes/sold

  • Example:

[
  {
    _id : '592400e0c9c4f40004754d40',
    qty : 4
  },
]

Developer Section

Want to contribute to and/or extend the application? Then this section's for you!

Prerequisites

Installation Guide

  1. Fork the repository.

  2. Clone the repository onto your dev machine.

  3. Navigate to the project root directory.

  4. Run npm install in the project root. This will install all dependencies that are included in the package.json.

Tools that are included in this app are:

  • Mongoose
  • ExpressJS
  • Body Parser
  1. To run tests, you will need to install Mocha.. This will allow you to run the mocha command in the terminal in order to run your unit tests.

  2. Run npm install nodemon to install nodemon. This will allow you to run the express server by using the command nodemon in your terminal while in the project's root.

Additional Notes

I have created a front-end application that uses this API. Consumers and developers alike may be interested in having a look at it as an example. You can find it here.

About

Shoe Catalogue API from Back-end Basics, codeX 2017 (2)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors