Add ping to dashboard, wait to get shared db

This commit is contained in:
Ben Gotow 2016-07-08 14:55:12 -07:00
parent 3e348252ab
commit 53a2e7e56b

View file

@ -20,7 +20,6 @@ const attach = (directory) => {
});
}
DatabaseConnector.forShared().then(({Account}) => {
server.register([HapiWebSocket, Inert], () => {
attach('./routes/')
@ -32,6 +31,7 @@ DatabaseConnector.forShared().then(({Account}) => {
websocket: {
only: true,
connect: (wss, ws) => {
DatabaseConnector.forShared().then(({Account}) => {
Account.findAll().then((accounts) => {
accounts.forEach((acct) => {
ws.send(JSON.stringify({ cmd: "ACCOUNT", payload: acct }));
@ -57,6 +57,7 @@ DatabaseConnector.forShared().then(({Account}) => {
ws.send(JSON.stringify({ cmd: "ASSIGNMENTS", payload: assignments}))
)
}, 1000);
});
},
disconnect: () => {
clearInterval(this.pollInterval);
@ -73,6 +74,18 @@ DatabaseConnector.forShared().then(({Account}) => {
},
});
server.route({
method: 'GET',
path: '/ping',
config: {
auth: false,
},
handler: (request, reply) => {
console.log("---> Ping!")
reply("pong")
},
});
server.route({
method: 'GET',
path: '/{param*}',
@ -88,4 +101,3 @@ DatabaseConnector.forShared().then(({Account}) => {
console.log('Dashboard running at:', server.info.uri);
});
});
});