Web application for publishing news.
The app requires docker and docker-compose. To execute it, enter the project root folder and run the following commands on your OS terminal:
docker-compose build
docker-compose up
The frontend application can be accessed through a web browser on the address http://localhost:3000
and the REST API on http://localhost:4000
.
Creates a new user.
email: string;
password: string
status code: 201
body: { "success": true }
status code: 400
message: "The x field is required"
status code: 409
message: "There is already a user created with this email"
status code: 500
message: "An unexpected error ocurred"
Log in with user credentials and gets an acess token. Note that all the access routes to news require this token.
email: string;
password: string
status code: 200
body: { "token": authorization-token }
status code: 400
message: "The x field is required"
status code: 401
message: "Wrong password"
status code: 404
message: "No user found with this email"
status code: 500
message: "An unexpected error ocurred"
Lists all the news
skip (optional): number, default: 0
limit (optional): number, default: 20
Authorization: string - Authorization token obtained on POST /login
status codes: 200, 206
body: [
{
"_id": "60f4e76976ccd5001fceb080",
"title": "Nice title",
"content": "Interesting content",
"createdAt": "2021-07-19T02:46:01.753Z"
}
]
status code: 401
message: "Invalid authorization token"
status code: 500
message: "An unexpected error ocurred"
Publish a new news
Authorization: string - Authorization token obtained on POST /login
title: string
content: string
status codes: 201
body: {
"success": true
}
status code: 400
message: "The request body cannot be empty"
status code: 400
message: "The x field is required"
status code: 500
message: "An unexpected error ocurred"
Find news by its id
Authorization: string - Authorization token obtained on POST /login
status codes: 200
body: {
"_id": "60f4e76976ccd5001fceb080",
"title": "Nice title",
"content": "Interesting content",
"createdAt": "2021-07-19T02:46:01.753Z"
}
status code: 401
message: "Invalid authorization token"
status code: 404
message: "News not found"
status code: 422
message: "The passed id is invalid"
status code: 500
message: "An unexpected error ocurred"
Updates one or more field of a news. Only one field is required.
Authorization: string - Authorization token obtained on POST /login
title: string;
content: string;
status codes: 204
body: {
"success": true,
}
status code: 400
message: "There must be at least one field on the request body"
status code: 401
message: "Invalid authorization token"
status code: 404
message: "News not found"
status code: 422
message: "The passed id is invalid"
status code: 500
message: "An unexpected error ocurred"
Delete news by its id
Authorization: string - Authorization token obtained on POST /login
status codes: 204
status code: 401
message: "Invalid authorization token"
status code: 404
message: "News not found"
status code: 422
message: "The passed id is invalid"
status code: 500
message: "An unexpected error ocurred"