Let's plan our first REST API. With Express, it is very easy and the development itself does not really differ from website development.
Here is a summary of what we want to implement as a REST API:
Resource (URI) |
POST (create) |
GET (read) |
PUT (update) |
DELETE (destroy) |
---|---|---|---|---|
|
Create new picture |
List pictures |
N/A (update all) |
N/A (destroy all) |
|
Error |
Show picture ID 1 |
Update picture ID 1 |
Destroy picture ID 1 |
The format is JSON
Bulk updates and bulk destroys are not safe, so we will not implement those
POST, GET, PUT, DELETE equals to CREATE, READ, UPDATE, DELETE, with the abbreviation CRUD