Commit 350ce343 authored by Yoann HOUPERT's avatar Yoann HOUPERT

init router webservice

parent 4817442a
......@@ -17,6 +17,8 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
const app = require('express')();
const routes = require('./lib/webserver/routes');
const config = require('./config.json');
......@@ -29,6 +31,7 @@ console.log('starting hublot...');
loader.loadAll('controller', 'lib', 'robot')
.then(modules => {
console.log('modules loaded... creating controller');
app.use('/', routes);
const controller = controllerFactory.create(runner, modules, config);
......@@ -37,6 +40,9 @@ loader.loadAll('controller', 'lib', 'robot')
// Note: client returned object can be used to control further the browser
// e.g.: let client = controller.client('room'); client.end();
controller.client('test-bot');
app.listen(config.api, () => {
console.log('App listening on port 3000');
});
})
.catch(err => {
console.error(err);
......
......@@ -36,5 +36,6 @@
"port": 8080,
"reconnectInterval": 5000
}
}
},
"api": 3000
}
const routes = require('express').Router();
routes.get('/connect/:room', (req, res) => {
//controller.client(req.params.room);
res.status(200).json({message: 'Room Name!' + req.params.room});
});
routes.get('/disconnect/:room', (req, res) => {
//controller.forceDisconnect(req.params.room);
res.status(200).json({message: 'Room Name!' + req.params.room});
});
routes.get('/test/', (req, res) => {
res.status(200).json({message: 'Room Test!'});
});
module.exports = routes;
......@@ -13,6 +13,8 @@
"webdriver-stop": "./bin/webdriver-stop"
},
"dependencies": {
"body-parser": "^1.18.2",
"express": "^4.16.2",
"mz": "2.6.0",
"webdriverio": "4.7.1"
},
......
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