Commit 5358b23f authored by Rosanny Sihombing's avatar Rosanny Sihombing
Browse files

clean-code

parent 40c92bc4
......@@ -239,7 +239,7 @@ const publicController = {
const emailSubject = 'Ihre Passwort-Anfrage an das Transferportal der HFT Stuttgart'
const emailContent = '<div>Lieber Nutzer,<br/><br/>' +
'<p>wir haben Ihre Anfrage zur Erneuerung Ihres Passwortes erhalten. Falls Sie diese Anfrage nicht gesendet haben, ignorieren Sie bitte diese E-Mail.<br/><br/>' +
'Sie können Ihr Passwort mit dem Klick auf diesen Link ändern: <a href="'+resetUrl+'">' + resetUrl + '</a><br/>' +
'Sie können Ihr Passwort mit dem Klick auf diesen Link ändern: <a href="' + resetUrl + '">' + resetUrl + '</a><br/>' +
'Dieser Link ist aus Sicherheitsgründen nur für 1 Stunde gültig.<br/></p>' + String(miscConst.mailSignature) + '</div>'
const credentialData = {
......
......@@ -4,10 +4,10 @@
* Module dependencies.
*/
//import {app} from './app';
const app = require('./app')
var debug = require('debug')('MLAB-Account:server');
// import {app} from './app';
import http from 'http'
const app = require('./app')
const debug = require('debug')('MLAB-Account:server')
const env = process.env.NODE_ENV ?? 'testing'
const config = require('./config/config')[env]
......@@ -16,68 +16,68 @@ const config = require('./config/config')[env]
* Get port from environment and store in Express.
*/
var port = normalizePort(process.env.PORT || config.app.port);
app.set('port', port);
const port = normalizePort(process.env.PORT || config.app.port)
app.set('port', port)
/**
* Create HTTP server.
*/
var server = http.createServer(app);
const server = http.createServer(app)
/**
* Listen on provided port, on all network interfaces.
*/
server.listen(port);
server.on('error', onError);
server.on('listening', onListening);
server.listen(port)
server.on('error', onError)
server.on('listening', onListening)
/**
* Normalize a port into a number, string, or false.
*/
function normalizePort(val: any) {
var port = parseInt(val, 10);
function normalizePort (val: any) {
const port = parseInt(val, 10)
if (isNaN(port)) {
// named pipe
return val;
return val
}
if (port >= 0) {
// port number
return port;
return port
}
return false;
return false
}
/**
* Event listener for HTTP server "error" event.
*/
function onError(error: any) {
function onError (error: any) {
if (error.syscall !== 'listen') {
throw error;
throw error
}
var bind = typeof port === 'string'
const bind = typeof port === 'string'
? 'Pipe ' + port
: 'Port ' + port;
: 'Port ' + port
// handle specific listen errors with friendly messages
switch (error.code) {
case 'EACCES':
console.error(bind + ' requires elevated privileges');
process.exit(1);
break;
console.error(bind + ' requires elevated privileges')
process.exit(1)
break
case 'EADDRINUSE':
console.error(bind + ' is already in use');
process.exit(1);
break;
console.error(bind + ' is already in use')
process.exit(1)
break
default:
throw error;
throw error
}
}
......@@ -85,10 +85,10 @@ function onError(error: any) {
* Event listener for HTTP server "listening" event.
*/
function onListening() {
var addr = server.address();
var bind = typeof addr === 'string'
function onListening () {
const addr = server.address()
const bind = typeof addr === 'string'
? 'pipe ' + addr
: 'port ' + addr!.port;
debug('Listening on ' + bind);
: 'port ' + addr!.port
debug('Listening on ' + bind)
}
Supports Markdown
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