- Routes
- Controllers & Actions
- DTO : Validations
- Response: CRUD, Errors
- Resolver
- Model/Entity
- Schema vs ActiveRecord vs DataMapper
- Search & Pagination
- Native query & Optimizing
- Caching
- DB Replication vs Sharding
- Multiple Database
- Blueprint routes
GET /resources - LIST - 200
GET /resources/:id - RETRIEVE A RESOURCE - 200/404
POST /resources - CREATE - 201
PATCH /resources/:id - UPDATE - 200/404
DELETE /resources/:id - DELETE - 204/404
- Success
curl -X POST http://localhost:1337/admins -H "Content-Type: application/json" --data '{"username": "sonnm","password":"13456", "email":"sonnm@yopmail.com", "firstName": "Son", "lastName": "Nguyen"}' -v
curl -X PATCH http://localhost:1337/admins/b46f5680-3dd5-4623-a7fd-f383a4cb2680 -H "Content-Type: application/json" --data '{"username": "sonnm","password":"123456"}' -v
curl -X DELETE http://localhost:1337/admins/3e1e0713-bf9d-4af2-8b23-931c0af3a6c2 -H "Content-Type: application/json" -v
// Create
{
"message": "Success",
"status": 201,
"data": {
"createdAt": 1603213704644,
"updatedAt": 1603213704644,
"id": "b46f5680-3dd5-4623-a7fd-f383a4cb2680",
"username": "sonnm",
"email": "sonnm@yopmail.com",
"status": "active",
"firstName": "Son",
"lastName": "Nguyen"
}
}
// Update
{
"message": "Success",
"status": 200,
"data": {
"createdAt": 1603213704644,
"updatedAt": 1603213884594,
"id": "b46f5680-3dd5-4623-a7fd-f383a4cb2680",
"username": "sonnm",
"email": "sonnm@yopmail.com",
"status": "active",
"firstName": "Son",
"lastName": "Nguyen"
}
}
// Delete
{
"message": "Success",
"status": 200,
"data": {}
}
- Validation Error
// 400 - Bad Request
{
"message": "Bad Request",
"status": 400,
"errors": [
{
"field": "username",
"message": "Username is duplicated"
},
{
"field": "email",
"message": "Email is duplicated"
}
]
}
// 404 - Not found
{
"message": "Not found",
"status": 404
}
// 500 - Internal Server Error
{
"message": "Internal Server Error",
"status": 500
}
- https://williamdurand.fr/2014/02/14/please-do-not-patch-like-an-idiot/
- https://symfonycasts.com/screencast/rest/patch
- https://restfulapi.net/http-methods/#:~:text=A%20successful%20response%20of%20DELETE,DELETE%20operations%20are%20idempotent.