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

init router webservice

parent 4817442a
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
* You should have received a copy of the GNU Affero General Public License * 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/>. * 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'); const config = require('./config.json');
...@@ -29,6 +31,7 @@ console.log('starting hublot...'); ...@@ -29,6 +31,7 @@ console.log('starting hublot...');
loader.loadAll('controller', 'lib', 'robot') loader.loadAll('controller', 'lib', 'robot')
.then(modules => { .then(modules => {
console.log('modules loaded... creating controller'); console.log('modules loaded... creating controller');
app.use('/', routes);
const controller = controllerFactory.create(runner, modules, config); const controller = controllerFactory.create(runner, modules, config);
...@@ -37,6 +40,9 @@ loader.loadAll('controller', 'lib', 'robot') ...@@ -37,6 +40,9 @@ loader.loadAll('controller', 'lib', 'robot')
// Note: client returned object can be used to control further the browser // Note: client returned object can be used to control further the browser
// e.g.: let client = controller.client('room'); client.end(); // e.g.: let client = controller.client('room'); client.end();
controller.client('test-bot'); controller.client('test-bot');
app.listen(config.api, () => {
console.log('App listening on port 3000');
});
}) })
.catch(err => { .catch(err => {
console.error(err); console.error(err);
......
...@@ -36,5 +36,6 @@ ...@@ -36,5 +36,6 @@
"port": 8080, "port": 8080,
"reconnectInterval": 5000 "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 @@ ...@@ -13,6 +13,8 @@
"webdriver-stop": "./bin/webdriver-stop" "webdriver-stop": "./bin/webdriver-stop"
}, },
"dependencies": { "dependencies": {
"body-parser": "^1.18.2",
"express": "^4.16.2",
"mz": "2.6.0", "mz": "2.6.0",
"webdriverio": "4.7.1" "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