ecomapi

See Post at: http://pixelhandler.com/blog/2012/02/09/develop-a-restful-api-using-node-js-with-express-and-mongoose/

Stars
11
Committers
1

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

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