-var createError = require('http-errors');
-var express = require('express');
-var path = require('path');
-var cookieParser = require('cookie-parser');
-var logger = require('morgan');
-var favicon = require('serve-favicon');
-var params = require('./config/parameters');
+const createError = require('http-errors');
+const express = require('express');
+const path = require('path');
+const cookieParser = require('cookie-parser');
+const logger = require('morgan');
+const favicon = require('serve-favicon');
+const params = require('./config/parameters');
-var app = express();
+let app = express();
app.use(favicon(path.join(__dirname, "static", "favicon.ico")));
* Module dependencies.
*/
-var app = require('../app');
-var debug = require('debug')('vc:server');
-var http = require('http');
+let app = require('../app');
+const debug = require('debug')('vc:server');
+const http = require('http');
/**
* Get port from environment and store in Express.
*/
-var port = normalizePort(process.env.PORT || '3000');
+const port = normalizePort(process.env.PORT || '3000');
app.set('port', port);
/**
* Create HTTP server.
*/
-var server = http.createServer(app);
+let server = http.createServer(app);
/*
* CRON tasks
*/
-var cron = require('node-cron');
-var UserModel = require("../models/User");
-var GameModel = require("../models/Game");
+let cron = require('node-cron');
+const UserModel = require("../models/User");
+const GameModel = require("../models/Game");
cron.schedule('0 0 0 * * *', function() {
// Remove unlogged users and unstarted games every 24h
UserModel.cleanUsersDb();
*/
function normalizePort(val) {
- var port = parseInt(val, 10);
+ const parsedPort = parseInt(val, 10);
- if (isNaN(port)) {
+ if (isNaN(parsedPort)) {
// named pipe
return val;
}
- if (port >= 0) {
+ if (parsedPort >= 0) {
// port number
- return port;
+ return parsedPort;
}
return false;
throw error;
}
- var bind = typeof port === 'string'
+ const bind = typeof port === 'string'
? 'Pipe ' + port
: 'Port ' + port;
*/
function onListening() {
- var addr = server.address();
- var bind = typeof addr === 'string'
+ const addr = server.address();
+ const bind = typeof addr === 'string'
? 'pipe ' + addr
: 'port ' + addr.port;
debug('Listening on ' + bind);
-var gulp = require('gulp');
-var nodemon = require('gulp-nodemon'); //reload server on changes
+const gulp = require('gulp');
+const nodemon = require('gulp-nodemon'); //reload server on changes
-var nodemonOptions = {
+const nodemonOptions = {
script: 'bin/www',
ext: 'js',
env: { 'NODE_ENV': 'development' },
-var db = require("../utils/database");
+const db = require("../utils/database");
const UserModel = require("./User");
/*
-var db = require("../utils/database");
+const db = require("../utils/database");
const UserModel = require("./User");
/*
-var db = require("../utils/database");
+const db = require("../utils/database");
/*
* Structure:
-var db = require("../utils/database");
+const db = require("../utils/database");
/*
* Structure:
-var db = require("../utils/database");
-var genToken = require("../utils/tokenGenerator");
-var params = require("../config/parameters");
-var sendEmail = require('../utils/mailer');
+const db = require("../utils/database");
+const genToken = require("../utils/tokenGenerator");
+const params = require("../config/parameters");
+const sendEmail = require('../utils/mailer');
/*
* Structure:
-var db = require("../utils/database");
+const db = require("../utils/database");
/*
* Structure:
const from = req.body["email"];
// Replace potential newline characters in subject
const subject = req.body["subject"].replace(/\r?\n|\r/g, " ");
- const body = req.body["content"]; //TODO: sanitize? Why? How?
+ const body = req.body["content"];
mailer(from, params.mail.contact, subject, body, err => {
if (!!err)