JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
public
.gitignore
Procfile
README.markdown
app-create-server.js
app-rest-product-embedded.js
app-rest-product.js
app.js
package.json
style.css

README.markdown

Build a RESTful api using node - ecommerce example

API for ecommerce application

Design

  • Simple API design and pragmatic REST - only 2 base URLs per resource
  • Keep verbs out of your base URLs
  • Our HTTP verbs are POST, GET, PUT, and DELETE (CRUD - Create, Read, Update, Delete)
  • Concrete names are better than abstract

Example : two resources (/products and /products/1) and the four HTTP verbs

Resource Post
(create)
Get
(read)
Put
(update)
Delete
(delete)
/products create a new product list products bulk update products delete all products
/products/1234 error show 1234 if exists update 1234, else error delete 1234

Nouns

Products

Product:

Id,  
Title,  
Description,  
Image URL,  
Categories: [ { Name } ],  
Style Number,  
Colors: [  
  {  
    Name,  
    Images: [  
      { Size, URL }  
    ],  
    Sizes: [  
      { Size, Available, SKU, Price }  
    ],  
  }  
]

Urls:

  • /products - list
  • /products/:id - single

Data: MongoDB using Mongoose with Express framework running with Node.js

Models are defined by passing a Schema instance to mongoose.model.

References