title: Get node.js server-side object available in client-side javascript code
body: <p>I played around with <a href="https://www.npmjs.com/package/uipath-orchestrator" rel="nofollow noreferrer"><strong>UiPath Orchestrator package</strong></a>. And the connection worked out with the installed node.js package.</p>
  <p>Anyway now I need to implement it in my website in a way where I get access it from a simple <code>html</code> site.</p>
  <p>There I struggle a bit with getting it to run. This is how I would like to use it:</p>
  <p>index.html:</p>
  <pre><code>&lt;html&gt;
    ...
    &lt;button onclick=&quot;test()&quot;&gt;Do something&lt;/button&gt;  
    ...
    &lt;script src=&quot;scripts.js&quot;&gt;&lt;/script&gt;
    ...
  &lt;/html&gt;
  </code></pre>
  <p>server.js: (I start with <code>node server.js</code>)</p>
  <pre><code>var http = require('http'),
      fs = require('fs');
  const port = 6543;
  const path = require('path');
  const server = http.createServer((req, res) =&gt; {
    let filePath = path.join(
        __dirname,
        req.url === &quot;/&quot; ? &quot;index.html&quot; : req.url
    );
    let extName = path.extname(filePath);
    let contentType = 'text/html';
    switch (extName) {
        case '.js':
            contentType = 'text/javascript';
            break;
    }
    console.log(`File path: ${filePath}`);
    console.log(`Content-Type: ${contentType}`);
    res.writeHead(200, {'Content-Type': contentType});
    const readStream = fs.createReadStream(filePath);
    readStream.pipe(res);
  });
  server.listen(port, (err) =&gt; {
  ...
  });
  </code></pre>
  <p>scripts.js:</p>
  <pre><code>function test() {
    ...
    // get the orch object here without defining it here as it contains credentials
    var orchestratorInstance = new Orchestrator({
      tenancyName: string (optional),
      usernameOrEmailAddress: string (required),
      password: string (required),
      hostname: string (required),
      isSecure: boolean (optional, default=true),
      port: integer (optional, [1..65535], default={443,80} depending on isSecure),
      invalidCertificate: boolean (optional, default=false),
      connectionPool: number (optional, 0=unlimited, default=1)
    });
  }
  </code></pre>
  <p>This works. So the test function is fired.</p>
  <p>But now I would like to get the <code>Orchestrator</code> object (like shown here <a href="https://www.npmjs.com/package/uipath-orchestrator" rel="nofollow noreferrer">https://www.npmjs.com/package/uipath-orchestrator</a>).</p>
  <p>How to do it in the best way?</p>
  <p>Maybe just pass-through that object to the <code>scripts.js</code> file itself? But how to do that with <code>window</code> or <code>global</code> and would that be a proper solution?</p>
  <p>I need the server-side generated object as it contains credentials that may not be delivered to client-side.</p>