Commit f779c790 authored by Anastasios Kalogeropoulos's avatar Anastasios Kalogeropoulos
Browse files

Merge branch 'facilitator-handler'

parents 32dad62a af258f98
const express = require('express')
const cors = require('cors')
const bodyParser = require('body-parser');
const app = express()
const port = 2999
app.use(bodyParser.json());
app.use(cors())
let facilitatorState = false;
/**
* Return the state of the facilitator
* true: facilitator is available to handle conversation
* false: facilitator cannot handle conversation
*/
app.get('/facilitator/status', cors(), (req, res) => {
console.log('Status change request');
let response = {"available": facilitatorState};
res.send(response)
})
/**
* Change the state of the facilitator to the given parameter [status]
*/
app.post('/facilitator/newStatus', cors(), (req, res) => {
let status = req.body['status'];
if(status === "true" || status === "false") {
facilitatorState = JSON.parse(status);
res.send("Status changed successfully to: " + facilitatorState.toString());
} else {
res.send("Cannot process request");
}
})
app.listen(port, () => console.log(`Example app listening on port ${port}!`))
\ No newline at end of file
......@@ -183,6 +183,15 @@
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
"integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw="
},
"cors": {
"version": "2.8.5",
"resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz",
"integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==",
"requires": {
"object-assign": "^4",
"vary": "^1"
}
},
"debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
......@@ -493,6 +502,11 @@
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz",
"integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk="
},
"object-assign": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
"integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM="
},
"object-keys": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.0.tgz",
......
......@@ -4,12 +4,13 @@
"description": "",
"main": "slack-server.js",
"scripts": {
"start": "node -r dotenv/config slack-server.js",
"start": "node -r dotenv/config slack-server.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"dependencies": {
"@slack/client": "^4.10.0",
"cors": "^2.8.5",
"express": "^4.16.4",
"uuid": "^3.3.2",
"ws": "^6.1.4"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment