我玩过UiPath Orchestrator 包。并且连接与安装的 node.js 包一起工作。
无论如何,现在我需要以一种从简单站点访问它的方式在我的网站中实现它html
。
在那里我很难让它运行。这就是我想使用它的方式:
索引.html:
<html>
...
<button onclick="test()">Do something</button>
...
<script src="scripts.js"></script>
...
</html>
server.js:(我从 开始node server.js)
var http = require('http'),
fs = require('fs');
const port = 6543;
const path = require('path');
const server = http.createServer((req, res) => {
let filePath = path.join(
__dirname,
req.url === "/" ? "index.html" : 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) => {
...
});
脚本.js:
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)
});
}
这行得通。所以测试函数被触发了。
但现在我想获取Orchestrator对象(如此处所示https://www.npmjs.com/package/uipath-orchestrator)。
如何以最好的方式做到这一点?
也许只是将该对象传递给scripts.js文件本身?但是如何用windowor做到这一点global,这会是一个合适的解决方案吗?
我需要服务器端生成的对象,因为它包含可能不会传送到客户端的凭据。
慕姐4208626
拉莫斯之舞
相关分类