title: Complete the middleware file such that, all the query parameters are validated and null and undefined values throw an error message
body: <p>output when both name and age parameters are passed.<br>
  problem statment for creating api:
  Complete the middleware file and index.js file in the given application such that, all the query parameters required by the route are validated and null and undefined values throw an error message -
  The query parameters that are compulsory are - name :String, age:Number</p>
  
  <p>create a route named '/query' and send response as explained above when this route is requested.
  according to me the the api should include these condition to get the desired output, they are:</p>
  
  <p>1.when both the query parameters are present respond with success(status:200)</p>
  
  <p>2.when age query parameter is entered and name parameter is empty then respond with failure(status:403)</p>
  
  <p>3.when name query parameter is entered and age parameter is empty then respond with failure(status:403)</p>
  
  <p>when one of the query parameters is null for "eg: <a href="http://localhost:3000/query/?age=2&amp;name" rel="nofollow noreferrer">http://localhost:3000/query/?age=2&amp;name</a>"</p>
  
  <pre><code>    the output i get is this: 
      {
       "error": false,
       "status": 200,
       "userMessage": "all parameters entered",
       "data": {
       "name": "",
       "age": "2"
      }
      }
  </code></pre>
  
  <p>but the expected output should have 
            error:true,
            status:403 
  this is error iam facing.</p>
  
  <p>there are two files. one is  index.js file and the other checkQueryParameters.js file.(this is a middleware)</p>
  
  <p>code of index.js</p>
  
  <pre><code>const express = require('express');
  const app = express();
  const middleware = require('./middleware/checkQueryParameter');
  
  app.get('/query',middleware.checkQueryParameters,(req,res)=&gt;{
  res.end();
  });
  app.listen(3000,()=&gt;console.log('Example app listening on point 
  3000'));
  module.exports = app;
  </code></pre>
  
  <p>code of checkQueryParameters.js</p>
  
  <pre><code>let checkQueryParameters = (req,res,next)=&gt;{
    let name = req.query.name;
    let age = req.query.age;
    console.log(typeof(age));
    console.log(typeof(name))
    console.log(age);
    console.log(name);
  
    if(typeof name == undefined || name == null){
    let result ={
        error : true,
        status : 403,
        userMessage : 'some parameters missing',
        data : 'name'
        }
        res.send(result);
       }
       else if(typeof age == undefined || age == null){
       let result ={
           error : true,
           status : 403,
           userMessage : 'all parameters missing',
           data : 'age'
          }
          res.send(result);
  
       }
       else{
           let result ={
           error : false,
           status : 200,
           userMessage : 'all parameters entered',
           data :{
                   'name' : name,
                    'age' : age
                 }
          }
        res.send(result);
  
       }
      }
  
     module.exports = {
        checkQueryParameters:checkQueryParameters
     }
  </code></pre>