-
Notifications
You must be signed in to change notification settings - Fork 0
/
statusMonitor.js
60 lines (55 loc) · 1.52 KB
/
statusMonitor.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
const axios = require("axios");
const mq = require("./queues");
const qh = require("./utils/QueueHelper");
/**
* Receives the Form posting, not suitable for multipart form data
* @param {*} req
* @param {*} res
* @param {*} next
*/
const receiveSubmitData = (req, res, next) => {
console.log(" IN: receiveSubmitData");
const formObject = req.body.data ;
res.locals.formObject = formObject;
next();
};
/**
*
* @param {*} req
* @param {*} res
* @param {*} next
*/
const returnResponse = (req, res) => {
console.log(" IN: returnResponse");
res.json(res.locals.returnResponse);
};
/**
* Publishes the status for document iri on the STATUS_Q
* @param {*} req
* @param {*} res
* @param {*} next
*/
const publishOnStatusQ = (req, res, next) => {
console.log(" IN: publishOnStatusQ");
const {iri, status, message, action} = res.locals.formObject;
qh.publishStatus(qh.formMsg(iri, status, message, action));
res.locals.returnResponse = {
'success': {
'code': 'publish_retract_status',
'message': res.locals.formObject
}
}
next();
};
/**
* API methods for each Request end point.
* You need to call next() at the end to ensure the next api in the chain
* gets called.
* Calling res.json(res.locals.returnResponse) will return the response
* without proceeding to the next method in the API stack.
*/
module.exports = {
receiveSubmitData: receiveSubmitData,
publishOnStatusQ: publishOnStatusQ,
returnResponse: returnResponse
};