This project is part of an application called cotabox-fullstack-challenge, who is part of a practical test for a job opportunity. It works together with the front-end to perform actions over a MongoDB Database.
With only the API, you can perform HTTP requests to perform actions over the Database, like add ou remove contributors, or just get information. This API is complementary to the front-end, but works alone as well.
A demo for this project is available on Heroku
https://cotabox-fullstack-challenge.herokuapp.com/
If you want to contribute, feel free to Clone this repository.
To start using, you need an MongoDB up and running (I really recommend MongoDB Atlas). After this, follow these steps in the project directory:
In the env-sample
file, put your MongoDB Connection String over the CONNECTION_STRING
and change the file name to .env
Run yarn init
or npm init
Run yarn dev
to work with nodemon, or just yarn start
or npm start
to just run the node start
Open http://localhost:3333 to view it in the browser.
If you have the VSCode REST Client extension, the file requests.http
will present a button called Send request
over every request on the file, just click there to send request inside the VSCode. But, if not, just copy the requests and the body (if needed) to your favorite REST Client, like Insomnia or Postman.
Follow this next endpoint documentation to understand the functionalities:
This GET will return a json list with all the contributors of the project, with they first names, last names and contribution.
This GET will return a json with the sum of all participants contribution.
This POST store a new participant on the database, and return it. If the participant already exists, this will return a JSON with an error
property, indicating that this client already exists.
This POST needs the JSON body bellow:
{
"firstName":"First Name",
"lastName":"Last Name",
"contribution":10
}
This DELETE remove an participant of the database, and return the result of deletion. If the participant doesn't exist, this will return a JSON with an error
property, indicating that this client doesn't exist.
This DELETE needs the JSON body bellow:
{
"firstName":"First Name",
"lastName":"Last Name"
}
Take care with this GET, this will wipe all data of the MongoDB Database.
Made with ❤️ and NodeJS by Lucas Augusto.