X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=bin%2Fwww;h=39c858488bc1b39e00709f1bd58f24f07c7e5c84;hb=HEAD;hp=c964949bf2fb186dc70a6511dac6fb7ac13a8ad7;hpb=e99c53fb3be56eb4c685dd061eef0e5b5bf22b73;p=qomet.git diff --git a/bin/www b/bin/www index c964949..39c8584 100755 --- a/bin/www +++ b/bin/www @@ -4,28 +4,28 @@ * Module dependencies. */ -var app = require('../app'); -var http = require('http'); +const app = require('../app'); +const http = require('http'); /** * Get port from environment and store in Express. */ -let port = normalizePort(process.env.PORT || '3000'); +const port = normalizePort(process.env.PORT || '3000'); app.set('port', port); /** * Create HTTP server. */ -let server = http.createServer(app); +const server = http.createServer(app); /* * CRON tasks */ -var cron = require('node-cron'); -var UserModel = require("../models/user"); +const cron = require('node-cron'); +const UserModel = require("../models/user"); cron.schedule('0 0 0 * * *', function() { // Remove unlogged users every 24h UserModel.cleanUsersDb(); @@ -38,8 +38,7 @@ cron.schedule('0 0 0 * * *', function() { server.listen(port); server.on('error', onError); server.on('listening', onListening); -let io = require('socket.io').listen(server); //sockets too -//https://stackoverflow.com/a/24610678/4640434 +const io = require('socket.io')(server); /* * Sockets handling @@ -53,7 +52,7 @@ require('../sockets')(io); function normalizePort(val) { - let port = parseInt(val, 10); + const port = parseInt(val, 10); if (isNaN(port)) // named pipe return val; @@ -73,7 +72,7 @@ function onError(error) if (error.syscall !== 'listen') throw error; - let bind = typeof port === 'string' + const bind = typeof port === 'string' ? 'Pipe ' + port : 'Port ' + port; @@ -99,8 +98,8 @@ function onError(error) function onListening() { - let addr = server.address(); - let bind = typeof addr === 'string' + const addr = server.address(); + const bind = typeof addr === 'string' ? 'pipe ' + addr : 'port ' + addr.port; console.log('Listening on ' + bind);