Create a back-end API using node.js and the express module

Create a back-end API using node.js and the express module

Task: To create a back-end API that supports the following routes:

1st route: api/quiz/list returns a json array with information about the all tests supported by the api. Should return only the quiz info such as id, title, and deception, not the list of quiz questions

2nd route: api/quiz/:quizid returns a single json object with the quiz information whose id equals to `:quizid` parameter in the route. Quiz id must be a field in the json, not the index of the quiz in the internal array storing the quizzes.

3rd route: api/quiz/:quizid/:questionid returns a single json object with data associated with a designated questione (i.e. question with id questionid ). The questions answer should NOT be included in this response. Moreover, the json request should have a meta field with a next_question subfiled that stores the id of the question that follows the current question in the quiz . If questionid is the last question in the quiz, next_question should be set to -1. If questionid is set to the value first then the route should return the data for the first question of the quiz.
{
      “data”: {
            “id” : 100,
            “question_type” : “multiple_choice”,
            “question” : “What is 1+1 equals to?”,
            “answer_options” : [“1″,”2″,”3″,”4”],
      },
      “meta” : {
            “next_question”: 101
}
}

4th route: api/check_answer/:quizid/:questionid/:answer : the route checks the :answer parameter against the correct answer of the question with id questionid and respond the results in a json object that include the following fields: correct is set to true if the question was answered correctly, false otherwise; feedback includes the feedback message to display to the user, this might be a short explanation about what is the correct answer, if the question as answer incorrectly, or an encouraging message if the question was answered incorrectly. Note that the parameter /:answer might encode different information about the answer depending on what type of question is answered. For example, in a multiple-choice question the :answer parameter might store the index of the correct answer option while in a text response question the :answer parameter might store the actual user text response. It is up to you, as the designer of the API to decide how to encode this parameter. A sample json response for this is provided below.
{
    “question_id” : 100,
    “user_answer” : “3”,
    “correct”: false,
    “feedback” : “The correct answer is 1 + 1 equals 2”
}

Create a second version of your front-end SPA

You are expected to create a second version of your SPA application that uses the RESTful API you created above and task advantage of the new features it provides. Make sure to create new files for this second version. Ex. index_milesone2.html and quiz_milestone2.js

1.    The list of quizzes is loaded asynchronously from the new API using the api/quiz/list route and the options are displayed in the SPA for the user to select.

2.    Each question is loaded asynchronously from the new API using the using a separate calls to the api/quiz/:quizid/:questionid route. You SPA application is expected to use the “next_question” field that comes with the response from the API to navigate between questions and recognize when the quiz is completed.

3.    The updated SPA should use the API route api/check_answer/:quizid/:questionid/:answer to evaluate the users answer to each question. Based on the JSON response you application should provide the appropriate feedback and update the score board.

1.    You RESTful API must be implemented using node.js and the express module.

2.    The routes of your application must be defined in their own module and use the express.Router() class.