Skip to content

Handling String Input

Sarthak Saxena edited this page Jul 28, 2021 · 2 revisions
  • To parse a text/plain request body, the express app needs to use express.text()).
  • Need to call the multer middleware within the endpoint body to handle the case in which file is not passed as an input.
  • Check if file has been passed as an input, if not, check if the request body is empty, if yes then throw an error response stating that the input has not been provided.
  • parseFileInput has to be renamed to parseInput as it'll take care of both file and string inputs now.
  • In case of parsing the string input, the syntax of the specification can be derived using JSON.parse(). If the string is successfully parsed, then it is a JSON, otherwise YAML.
  • Logic to parse the string remains same as before.
Clone this wiki locally