This is a back-end project based on Twitter. The API has the objective of providing routes that will allow users to log in, view tweets, and create new tweets.
A route to create a new user account. If the request is wrong it'll return a error status 400 and an error message indicating that all the fields are required and shouldn't be empty. The request body should be:
{
username: "bobesponja",
avatar: "https://cdn.shopify.com/s/files/1/0150/0643/3380/files/Screen_Shot_2019-07-01_at_11.35.42_AM_370x230@2x.png"
}
A route that will retrieve a list of tweets, paginated by default to 10 tweets per page. To specify a different page, use the page query parameter, e.g. ?page=2. If the page parameter is not provided or is invalid, a 400 status code error will be returned. If there are no tweets, it'll return an empty array. The response will come like that:
[
{
username: "bobesponja",
avatar: "https://cdn.shopify.com/s/files/1/0150/0643/3380/files/Screen_Shot_2019-07-01_at_11.35.42_AM_370x230@2x.png",
tweet: "Eu amo hambúrguer de siri!"
}
]
A request to create new tweets. All the fields are required and can't be empty. The username should come as a header. If any of the fields are missing or empty, the API will respond with a 400 status code and an error message indicating that all the fields are required and shouldn't be empty.
The header should be like this:
{
user: "username"
}
While the request body should be:
{
tweet: "Eu amo hambúrguer de siri!"
}
A request that will retrieve a list of tweets created by the user specified in the params. If there are no tweets, it'll return an empty array. The response will come like that:
[
{
username: "bobesponja",
avatar: "https://cdn.shopify.com/s/files/1/0150/0643/3380/files/Screen_Shot_2019-07-01_at_11.35.42_AM_370x230@2x.png",
tweet: "Eu amo hambúrguer de siri!"
},
{
username: "bobesponja",
avatar: "https://cdn.shopify.com/s/files/1/0150/0643/3380/files/Screen_Shot_2019-07-01_at_11.35.42_AM_370x230@2x.png",
tweet: "Eu sou amigo do Patrick, ele é uma estrela!"
}
]
- Clone this repository
- Install the dependencies
npm i
- Run the back-end with
npm start
- Access http://localhost:5000 on your browser to run the API.