@contrast/screener-service
This module houses client code for talking to either the local or cloud provisioning services as well as RMQ interfacing.
Install
npm i @contrast/screener-service
API
Creating a session
const provisioningClient = require('@contrast/screener-service').client;
const response = await provisioningClient.createSession(
process.env.SCREENER_AGENT_URL
);
const { id: sessionId } = response;
const { hostname, port, username, password } = response.mq;
Starting an app
const { id: appId, url: appUrl } = await provisioningClient.startApp({
sessionId,
'express',
port: 3000,
'12',
'assess',
agentUrl: process.env.SCREENER_AGENT_URL
});
Polling an app
await provisioningClient.pollApp({ appUrl });
Stopping an app
await provisioningClient.stopApp(appId);
Interacting with Rabbit MQ
const RmqClient = require('@contrast/screener-service').rmqClient;
// connect
const mq = new RmqClient(`amap://${username}:${password}@${hostname}:${port}`, exchangeName);
await mq.connect();
// create a queue
await mq.createQueue(queueName);
// poll for message
const msg = await mq.getMessage(queueName, msgType, timeout);