It is an API for Polling which helps a User to raise a Question, he/she or others can add option to that question and can vote on that options as well.
- How to Setup the Code into your System
- Cloning the repository using VS Code
- Tech Used in it
- Detailed API's Functionality
- Support
- Fork this repository into your github account (create one if you don't have it yet)
- Clone it to your system (
git clone
) - In the terminal run git remote add upstream
https://github.com/pratik-dutta/pollingAPI.git
(this is for taking a fresh update of the code anytime in the future)
- Open VS Code.
- Go to View > Terminal.
- To clone the repo to your desktop, change the directory to desktop by running the command
cd desktop
. - In the terminal, run
git clone https://github.com/pratik-dutta/pollingAPI.git
. - A folder/directory should be created on your desktop.
- Open that folder in VS Code, go to File > Open.
- Run
npm install
to download dependencies of the project or you can download it by seeing dependencies inpackage.json
. - Now you're good to go!
Stack: NodeJs, ExpressJs, MongoDB
This API helps to performs the following function
- Create a Question
- Add Option to a Question
- Delete a Question
- Add vote to an Option
- Delete an Option
- View a Question
Following is the description of all the function mentioned above.
-
/questions/create
This route helps to create a question. -
/questions/:id/options/create
This route helps to add different options to a particular question. The id of question is specified in the route params. The opions should be unique. -
/questions/:id/delete
This route helps to delete a question. It deletes the question only if it's option doesn't have votes in it. -
/options/:id/add_vote
This route helps to increment the vote of a particular option. The option id is specified in the route. -
/options/:id/delete
This route helps to delete an option of a question. It deletes the option only if there is no votes. -
/questions/:id
This route helps to view a question and all the option associated with it and the votes of option as well.
Feel free to contact at pratikdutta.786(at)gmail(dot)com for any query.