Skip to content

ncgc/desafio-conceitos-nodejs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GoStack

Challenge 02: Node.js Concepts

“Don't wait to plant, only have patience to harvest”!

🚀 About the challenge

Thils will be an application to storage repositories of your portfolio, that will allow you to list, update, and delete repositories, and besides that, the repositories can also receive likes.

Application Routes

Now that you already have the template cloned, and ready to continue, you must open the file app.js, and complete the places where there's no have code, with the code to achieve the goals of each route.

  • POST /repositories: The route must receive title, URL, and techs inside of the request body. The URL must be the link to the Github of that repository. When registering a new project, it must be stored inside an object in the following format: {id:" uuid ", title: 'Desafio Node.js', URL: 'http: //github.com / ...' , techs: ["Node.js", "..."], likes: 0} ; Make sure the ID is a UUID, and always start likes as 0.

  • GET /repositories: The route that lists all repositories;

  • PUT /repositories/:id: The route should only change the title, URL and techs of the repository that has the id equal to the id present in the route parameters;

  • DELETE /repositories/:id: The route must delete a repository with the id present in the route parameters;

  • POST /repositories/:id/like: The route must increase the number of likes from the specific repository chosen through the id param present in the route parameters, at each call of this route, the number of likes must be increased by 1;

Tests Specification

For this challenge we have the following tests:

  • should be able to create a new repository: In order for this test to pass, your application must allow a repository to be created, and return a JSON with the created project.

  • should be able to list the repositories: In order for this test to pass, your application must return an array with all the repositories that have been created so far.

  • should be able to update repository: In order for this test to pass, your application must allow only the url, title and techs fields to be changed.

  • should not be able to update a repository that does not exist: In order for this test to pass, you must validate in your update route whether the repository id sent by the URL exists or not. If not, return an error with status 400.

  • should not be able to update repository likes manually: In order for this test to pass, you must not allow your update route to directly change the likes of that repository, maintaining the same number of likes that the repository already had before the update. That's because the only place that should update this information is the route responsible for increasing the number of likes.

  • should be able to delete the repository: In order for this test to pass, you must allow your delete route to delete a project, and when deleted, it must return an empty response, with status 204.

  • should not be able to delete a repository that does not exist: In order for this test to pass, you must validate in your delete route whether the repository id sent by the URL exists or not. If not, return an error with status 400.

  • should be able to give a like to the repository: In order for this test to pass, your application must allow a repository with the given id to receive likes. The value of likes must be increased by 1 for each request, and as the result, return a JSON containing the repository with the number of likes updated.

  • should not be able to like a repository that does not exist: In order for this test to pass, you must validate in your like route whether the repository id sent by the URL exists or not. If not, return an error with status 400.

📝 Licence

This project is under license from MIT. See the archive LICENSE to more details.

About

🚀 Desafio 02 GoStack Rocketseat

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published