title: How can i call my routes from express app instance?
body: <p>I have a cronjob on my server that interfaces my REST Api running in a different node process like this:</p>
  
  <pre><code>request({
      url: 'http://example.com/abc',
      method: "POST",
      json: data
  }, function (error, response, body) {
      console.log(body);
  });
  </code></pre>
  
  <p>This blocks my User interface while the cronjob is sending data.</p>
  
  <p>My idea was to export the app and require it in my cronjob and call the routes directly from there.
  Similar to what you do when using <a href="https://www.npmjs.com/package/supertest" rel="nofollow noreferrer">supertest</a>.</p>
  
  <p>The problem is i can't figure out how to call the route. </p>
  
  <p><strong>app.js</strong></p>
  
  <pre><code>const express = require('express');
  const app = express();
  // ...
  module.exports = app;
  </code></pre>
  
  <p><strong>cronjob.js</strong></p>
  
  <pre><code>const app = require('../../app');
  
  function pushIt(url, data, apiKey) {
      // make POST request to app here
  }
  </code></pre>
  
  <p>Is this possible somehow? The reason I want to do is I want to have the load of the POST request in the cronjob process with its own app instance.
  So that the public api is not slowed down when running the cronjob.</p>
  
  <p>Thanks for your help.</p>