0.3.1 • Published 4 years ago
tranel-http v0.3.1
更优雅的远程调用 http。
像本地访问一样去服务函数调用和值读取
示例:
server:
const tranelHttp = new TranelHttp();
tranelHttp.proxy({
proxyObject: { // 在服务器端代理的对象
cpuInfo: os.cpus()[0],
getSystemInfo() {
return os.platform();
},
dnsLookup(domain: string) {
return new Promise((rs, rj) => {
dns.lookup(domain, (err, address) => {
if (err) { rj(err); }
else { rs(address); }
});
});
},
},
});
client:
const cpu = await p.cpuInfo.model; // 在客户端直接读取
const sysInfo = await p.getSystemInfo();
const ip = await p.dnsLookup($dnsDomain.value);
详情: 请查看packages/tranel-http/examples