- 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 |
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
Models are defined by passing a Schema instance to mongoose.model.
- API design nouns are good, verbs are bad
- Models are defined by passing a Schema instance to mongoose.model
- SchemaTypes take care of validation, casting, defaults, and other general options in our models
- Embedded documents are documents with schemas of their own that are part of other documents
- Backbone Todo boilerplates demonstrating integration with Node.js, Express, MongoDB