Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function request(
service: string,
...req: string[]
): Promise {
const socket = new Request({receiveTimeout: 2000})
socket.connect(broker.address)
console.log(`requesting '${req.join(", ")}' from '${service}'`)
await socket.send(["MDPC01", service, ...req])
try {
const [blank, header, ...res] = await socket.receive()
console.log(`received '${res.join(", ")}' from '${service}'`)
return res
} catch (err) {
console.log(`timeout expired waiting for '${service}'`)
}
}