title: ExpressJS backend put requests into a queue
body: <p>I have clients sending tasks to be performed by the server but these requests should be handled in a queue like fashion. Any idea how I can do this? Thanks.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>    express.Router().post('/tasks', function(req, res){
        //This is the task to perform. While being performed, another user
        //might send a request AND should only be processed when this is done.
        //This should also flag the pending task if it is completed.
  
        Promise.resolve(req.body)
        .then(function() {
        //..
        })
        .catch(function(error) {
          //....
        })
  
      })</code></pre>
  </div>
  </div>
  </p>