title: Time Out in Api rest Express Nodejs
body: <p>I want to put my api in time out. I tried to put it in a "global" way when I create the server but the answer only says that no data was returned, not a 504 error. I also have the option to place it for each route, I think the time out should go in the controller of my app .</p>
  
  <pre><code>function initialize() {
    return new Promise((resolve, reject) =&gt; {
      const app = express();
      httpServer = http.createServer(app);
      app.use(morgan('combined'));
      app.use('/proyecto', router_proyecto);
      app.use('/tramitacion',router_tramitacion);
      httpServer.listen(webServerConfig.port, err =&gt; {
        if (err) {
          reject(err);
          return;
        }
      //httpServer.timeout = 500;
        console.log('Servidor web escuchando en puerto:'+webServerConfig.port);
        resolve();
      });
    });
  }
  </code></pre>
  
  <p>exaple of a route:</p>
  
  <pre><code>router_proyecto.route('/getProyecto/:proyid?')
      .get(proyecto.getProyecto);
  </code></pre>
  
  <p>Controller(Time out should go here):</p>
  
  <pre><code>async function getProyecto(req, res, next) {
    try {
      const context = {};
      context.proyid = parseInt(req.params.proyid, 10);
      const rows = await proyectos.getProyecto_BD(context);
      if (rows.length &gt;0) {
        res.status(200).json(rows);
      } else {
        res.status(404).end();
      }
      } catch (err) {
      next(err);
    }
  }
  module.exports.getProyecto = getProyecto;
  </code></pre>