List of available endpoints:
POST /register
POST /login
GET /categories
POST /posts
GET /posts
GET /posts/:id
DELETE /posts/:id
- Create a new user data
body
{
"email": "string (required)",
"password": "string (required)"
}
200 - Ok
{
"status": "string",
"data": {
"id": "integer",
"email": "string"
}
}
400 - Bad Request
{
"message": ["Email cannot be null", "Password cannot be null"]
}
or
{
"message": ["Email cannot be empty", "Password cannot be empty"]
}
or
{
"message": ["Password must be between 5 and 20 characters"]
}
or
{
"message": ["email must be unique"]
}
- Enter into the system
body
{
"email": "string (required)",
"password": "string (required)"
}
200 - Ok
{
"status": "string",
"access_token": "string",
"data": {
"id": "integer",
"email": "string"
}
}
401 - Unauthorized
{
"message": "Invalid email/password"
}
- Get all the categories data
headers
{
"access_token": "string (required)"
}
200 - Ok
{
"status": "string",
"data": [
{
"id": "integer",
"name": "string",
"createdAt": "date",
"updatedAt": "date"
},
...,
]
}
- Create a new post data
headers
{
"access_token": "string (required)"
}
body
{
"title": "string (required)",
"content": "string (required)",
"imgUrl": "string",
"CategoryId": "integer",
"AuthorId": "integer"
}
201 - Created
{
"status": "string",
"data": {
"id": "integer",
"title": "string",
"content": "string",
"imgUrl": "string",
"CategoryId": "integer",
"AuthorId": "integer",
"updatedAt": "date",
"createdAt": "date"
}
}
400 - Bad Request
{
"message": ["Title cannot be null", "Content cannot be null"]
}
or
{
"message": ["Title cannot be empty", "Content cannot be empty"]
}
Description:
- Get all posts from database
headers
{
"access_token": "string (required)"
}
200 - OK
{
"status": "ok",
"data": [
{
"id": "integer",
"title": "string",
"content": "string",
"imgUrl": "string",
"CategoryId": "integer",
"AuthorId": "integer",
"createdAt": "date",
"updatedAt": "date"
},
...,
]
}
Description:
- Get post by id
headers
{
"access_token": "string (required)"
}
params
{
"id": "integer (required)"
}
200 - OK
{
"status": "string",
"data": {
"id": "integer",
"title": "string",
"content": "string",
"imgUrl": "string",
"CategoryId": "integer",
"AuthorId": "integer",
"createdAt": "date",
"updatedAt": "date"
}
}
404 - Not Found
{
"message": "Post not found"
}
Description:
- Delete post by id
params
{
"id": "integer (required)"
}
200 - OK
{
"message": "<entity name> success to delete"
}
403 - Forbidden
{
"message": "You are not authorized to access this page"
}
404 - Not Found
{
"message": "Movie not found"
}
401 - Unauthorized
{
"message": "Invalid token"
}
500 - Internal Server Error
{
"message": "Internal server error"
}