Skip to content

AakashSundarS/intern-selection-task

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Custom Form Generation API

Quick Start

  • Clone repository
git clone https://github.com/ArunMurugan78/intern-selection-task.git
  • Install dependencies
yarn 
  • The following env variables are available to configure the application. Add them to the .env file.
PORT=
MONGO_URI=

The default configuration tries to connect to the mongo instance running locally (127.0.0.1:27017). The default PORT is 8000.

Routes

  • POST /form/new - Creates a new form. The post data should have the content type as application/json and the body data should be of the following form.
{
    "fields": [ { "type": "RADIO" }, { "type": "CHECKBOX" }, { "type" : "TEXT" } ]
}

Field type should be one of RADIO, TEXT, CHECKBOX. The response is of the following form.

{  
   "formId": "617a2ae30f9b0385ae9ef5c7"
}

This request can be made in cURL like the following

 curl -X POST -d '{"fields": [ {"type": "RADIO" }, {"type": "TEXT"} ]}' -H "Content-Type: application/json" https://localhost:8000/form/new
{"formId":"617a2b4c0f9b0385ae9ef5cb"}
  • GET /form/:id - The response data contains the form information.
 curl https://localhost:8000/form/617a2b4c0f9b0385ae9ef5cb
{"_id":"617a2b4c0f9b0385ae9ef5cb","fields":[{"type":"RADIO","_id":"617a2b4c0f9b0385ae9ef5cc"},{"type":"TEXT","_id":"617a2b4c0f9b0385ae9ef5cd"}],"__v":0}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published