From 5358b23f43612a352e1dad77832b45f9e591d97a Mon Sep 17 00:00:00 2001 From: Rosanny <rosanny.sihombing@hft-stuttgart.de> Date: Mon, 1 Aug 2022 14:30:46 +0200 Subject: [PATCH] clean-code --- src/app.ts | 2 +- src/controller/publicController.ts | 2 +- src/index.ts | 60 +++++++++++++++--------------- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/app.ts b/src/app.ts index 59f673c1..e27fa210 100644 --- a/src/app.ts +++ b/src/app.ts @@ -85,4 +85,4 @@ app.use(function (err: any, req: any, res: any, next: any) { }) // export { app } -module.exports = app \ No newline at end of file +module.exports = app diff --git a/src/controller/publicController.ts b/src/controller/publicController.ts index 06a83621..18f90e1a 100644 --- a/src/controller/publicController.ts +++ b/src/controller/publicController.ts @@ -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 = { diff --git a/src/index.ts b/src/index.ts index 22f384c5..c0f0a856 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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) } -- GitLab