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

clean-code

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