Skip to content

jajabailio/comment-loop

Repository files navigation

CommentLoop

Setup

Notes: You can use local Mongodb server to connect to the database.

  1. Install packages

    npm install --save
  2. Start application

    npm start

Testing Routes

You can test the following endpoints in Postman (or other alternatives)


CREATE Survey - POST - "/api/surveys"

  • Open the "sample-body.js" file to get a sample JSON object to create a new Survey.

    Upon Creation, a "mainId" is added in the object, which will hold the _id of the first instance of this template. You will also find a "version_number".

UPDATE Survey - PUT - "/api/surveys/:id"

  • The "id" parameter is the "mainId" field in the Survey schema.

  • You can use the same json data used in the POST survey route. Just change the value of the "name" field, or a question's/option's "text" field to another value.

    When updating a template, it will create a new instance of the Survey, but will hold the "mainId" with the "_id" of the first instance created in the collection. You will notice in the DB that the "version_number" has increased and the "isActive" from the previous instance is now false as opposed to the updated instance will have the "isActive" set to true.

FETCH Survey - GET - "/api/surveys/:id"

  • The "id" parameter is the "mainId" in the Survey schema. The api will fetch the instance with the "isActive" set to true.
  • You can also fetch a list of surveys by omitting the "id" parameter.

FETCH Response by Survey - GET - "/api/survey/responses/:id"

  • This endpoint will fetch the survey details, as well as the options answered from different responses.

CREATE Response - POST - "/api/responses"

  • Open the "sample-body.js" file to get a sample JSON object to create a new Response.

FETCH Response - GET - "/api/responses/:id"

  • The "id" params is the "_id" for the Response schema.

    In the "sample-body.js" file, you can follow the guide to have a data ready to test

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors