code cleanup
parent
cc6de92bdc
commit
4dca27d34b
6
app.js
6
app.js
|
|
@ -114,7 +114,7 @@ app.use((request, response, next) => {
|
|||
response.locals.urlPrefix = configFunctions.getProperty('reverseProxy.urlPrefix');
|
||||
next();
|
||||
});
|
||||
app.get(urlPrefix + '/', sessionChecker, (_request, response) => {
|
||||
app.get(`${urlPrefix}/`, sessionChecker, (_request, response) => {
|
||||
response.redirect(`${urlPrefix}/dashboard`);
|
||||
});
|
||||
app.use(`${urlPrefix}/dashboard`, sessionChecker, routerDashboard);
|
||||
|
|
@ -137,11 +137,11 @@ app.get(`${urlPrefix}/logout`, (request, response) => {
|
|||
Object.hasOwn(request.cookies, sessionCookieName)) {
|
||||
request.session.destroy(() => {
|
||||
response.clearCookie(sessionCookieName);
|
||||
response.redirect(urlPrefix + '/');
|
||||
response.redirect(`${urlPrefix}/`);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response.redirect(urlPrefix + '/login');
|
||||
response.redirect(`${urlPrefix}/login`);
|
||||
}
|
||||
});
|
||||
app.use((request, _response, next) => {
|
||||
|
|
|
|||
6
app.ts
6
app.ts
|
|
@ -225,7 +225,7 @@ app.use((request, response, next) => {
|
|||
next()
|
||||
})
|
||||
|
||||
app.get(urlPrefix + '/', sessionChecker, (_request, response) => {
|
||||
app.get(`${urlPrefix}/`, sessionChecker, (_request, response) => {
|
||||
response.redirect(`${urlPrefix}/dashboard`)
|
||||
})
|
||||
|
||||
|
|
@ -266,10 +266,10 @@ app.get(`${urlPrefix}/logout`, (request, response) => {
|
|||
) {
|
||||
request.session.destroy(() => {
|
||||
response.clearCookie(sessionCookieName)
|
||||
response.redirect(urlPrefix + '/')
|
||||
response.redirect(`${urlPrefix}/`)
|
||||
})
|
||||
} else {
|
||||
response.redirect(urlPrefix + '/login')
|
||||
response.redirect(`${urlPrefix}/login`)
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -9,13 +9,12 @@ import * as configFunctions from '../helpers/functions.config.js';
|
|||
const debug = Debug(`lot-occupancy-system:www:${process.pid}`);
|
||||
const directoryName = dirname(fileURLToPath(import.meta.url));
|
||||
const processCount = Math.min(configFunctions.getProperty('application.maximumProcesses'), os.cpus().length);
|
||||
process.title =
|
||||
configFunctions.getProperty('application.applicationName') + ' (Primary)';
|
||||
process.title = `${configFunctions.getProperty('application.applicationName')} (Primary)`;
|
||||
debug(`Primary pid: ${process.pid}`);
|
||||
debug(`Primary title: ${process.title}`);
|
||||
debug(`Launching ${processCount} processes`);
|
||||
const clusterSettings = {
|
||||
exec: directoryName + '/wwwProcess.js'
|
||||
exec: `${directoryName}/wwwProcess.js`
|
||||
};
|
||||
cluster.setupPrimary(clusterSettings);
|
||||
const activeWorkers = new Map();
|
||||
|
|
|
|||
|
|
@ -19,15 +19,16 @@ const processCount = Math.min(
|
|||
os.cpus().length
|
||||
)
|
||||
|
||||
process.title =
|
||||
configFunctions.getProperty('application.applicationName') + ' (Primary)'
|
||||
process.title = `${configFunctions.getProperty(
|
||||
'application.applicationName'
|
||||
)} (Primary)`
|
||||
|
||||
debug(`Primary pid: ${process.pid}`)
|
||||
debug(`Primary title: ${process.title}`)
|
||||
debug(`Launching ${processCount} processes`)
|
||||
|
||||
const clusterSettings = {
|
||||
exec: directoryName + '/wwwProcess.js'
|
||||
exec: `${directoryName}/wwwProcess.js`
|
||||
}
|
||||
|
||||
cluster.setupPrimary(clusterSettings)
|
||||
|
|
|
|||
|
|
@ -25,12 +25,11 @@ function onError(error) {
|
|||
function onListening(server) {
|
||||
const addr = server.address();
|
||||
if (addr !== null) {
|
||||
const bind = typeof addr === 'string' ? 'pipe ' + addr : 'port ' + addr.port.toString();
|
||||
debug('HTTP Listening on ' + bind);
|
||||
const bind = typeof addr === 'string' ? `pipe ${addr}` : `port ${addr.port.toString()}`;
|
||||
debug(`HTTP Listening on ${bind}`);
|
||||
}
|
||||
}
|
||||
process.title =
|
||||
configFunctions.getProperty('application.applicationName') + ' (Worker)';
|
||||
process.title = `${configFunctions.getProperty('application.applicationName')} (Worker)`;
|
||||
const httpPort = configFunctions.getProperty('application.httpPort');
|
||||
const httpServer = http.createServer(app);
|
||||
httpServer.listen(httpPort);
|
||||
|
|
|
|||
|
|
@ -49,8 +49,8 @@ function onListening(server: http.Server): void {
|
|||
|
||||
if (addr !== null) {
|
||||
const bind =
|
||||
typeof addr === 'string' ? 'pipe ' + addr : 'port ' + addr.port.toString()
|
||||
debug('HTTP Listening on ' + bind)
|
||||
typeof addr === 'string' ? `pipe ${addr}` : `port ${addr.port.toString()}`
|
||||
debug(`HTTP Listening on ${bind}`)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -58,8 +58,9 @@ function onListening(server: http.Server): void {
|
|||
* Initialize HTTP
|
||||
*/
|
||||
|
||||
process.title =
|
||||
configFunctions.getProperty('application.applicationName') + ' (Worker)'
|
||||
process.title = `${configFunctions.getProperty(
|
||||
'application.applicationName'
|
||||
)} (Worker)`
|
||||
|
||||
const httpPort = configFunctions.getProperty('application.httpPort')
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ const forbiddenJSON = {
|
|||
success: false,
|
||||
message: 'Forbidden'
|
||||
};
|
||||
const forbiddenRedirectURL = urlPrefix + '/dashboard/?error=accessDenied';
|
||||
const forbiddenRedirectURL = `${urlPrefix}/dashboard/?error=accessDenied`;
|
||||
export function adminGetHandler(request, response, next) {
|
||||
if (userFunctions.userIsAdmin(request)) {
|
||||
next();
|
||||
|
|
@ -40,6 +40,6 @@ export async function apiGetHandler(request, response, next) {
|
|||
next();
|
||||
}
|
||||
else {
|
||||
response.redirect(urlPrefix + '/login');
|
||||
response.redirect(`${urlPrefix}/login`);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ const forbiddenJSON = {
|
|||
message: 'Forbidden'
|
||||
}
|
||||
|
||||
const forbiddenRedirectURL = urlPrefix + '/dashboard/?error=accessDenied'
|
||||
const forbiddenRedirectURL = `${urlPrefix}/dashboard/?error=accessDenied`
|
||||
|
||||
export function adminGetHandler(
|
||||
request: Request,
|
||||
|
|
@ -74,6 +74,6 @@ export async function apiGetHandler(
|
|||
if (await userFunctions.apiKeyIsValid(request)) {
|
||||
next()
|
||||
} else {
|
||||
response.redirect(urlPrefix + '/login')
|
||||
response.redirect(`${urlPrefix}/login`)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,14 +79,15 @@ function getMapByMapDescription(mapDescription) {
|
|||
return map;
|
||||
}
|
||||
function formatDateString(year, month, day) {
|
||||
return (`0000${year}`.slice(-4) +
|
||||
'-' +
|
||||
`00${month}`.slice(-2) +
|
||||
'-' +
|
||||
`00${day}`.slice(-2));
|
||||
const formattedYear = `0000${year}`.slice(-4);
|
||||
const formattedMonth = `00${month}`.slice(-2);
|
||||
const formattedDay = `00${day}`.slice(-2);
|
||||
return `${formattedYear}-${formattedMonth}-${formattedDay}`;
|
||||
}
|
||||
function formatTimeString(hour, minute) {
|
||||
return `00${hour}`.slice(-2) + ':' + `00${minute}`.slice(-2);
|
||||
const formattedHour = `00${hour}`.slice(-2);
|
||||
const formattedMinute = `00${minute}`.slice(-2);
|
||||
return `${formattedHour}:${formattedMinute}`;
|
||||
}
|
||||
const cemeteryToMapName = {
|
||||
'00': 'Crematorium',
|
||||
|
|
|
|||
|
|
@ -245,17 +245,18 @@ function getMapByMapDescription(mapDescription: string): recordTypes.MapRecord {
|
|||
}
|
||||
|
||||
function formatDateString(year: string, month: string, day: string): string {
|
||||
return (
|
||||
`0000${year}`.slice(-4) +
|
||||
'-' +
|
||||
`00${month}`.slice(-2) +
|
||||
'-' +
|
||||
`00${day}`.slice(-2)
|
||||
)
|
||||
const formattedYear = `0000${year}`.slice(-4)
|
||||
const formattedMonth = `00${month}`.slice(-2)
|
||||
const formattedDay = `00${day}`.slice(-2)
|
||||
|
||||
return `${formattedYear}-${formattedMonth}-${formattedDay}`
|
||||
}
|
||||
|
||||
function formatTimeString(hour: string, minute: string): string {
|
||||
return `00${hour}`.slice(-2) + ':' + `00${minute}`.slice(-2)
|
||||
const formattedHour = `00${hour}`.slice(-2)
|
||||
const formattedMinute = `00${minute}`.slice(-2)
|
||||
|
||||
return `${formattedHour}:${formattedMinute}`
|
||||
}
|
||||
|
||||
const cemeteryToMapName = {
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
import * as importIds from './legacy.importFromCsv.ids.js';
|
||||
export function buildLotName(lotNamePieces) {
|
||||
return (lotNamePieces.cemetery +
|
||||
'-' +
|
||||
(lotNamePieces.block === '' ? '' : `B${lotNamePieces.block}-`) +
|
||||
(lotNamePieces.range1 === '0' && lotNamePieces.range2 === ''
|
||||
? ''
|
||||
: `R${lotNamePieces.range1 === '0' ? '' : lotNamePieces.range1}${lotNamePieces.range2}-`) +
|
||||
(lotNamePieces.lot1 === '0' && lotNamePieces.lot2 === ''
|
||||
? ''
|
||||
: `L${lotNamePieces.lot1}${lotNamePieces.lot2}-`) +
|
||||
`G${lotNamePieces.grave1}${lotNamePieces.grave2}` +
|
||||
', ' +
|
||||
`Interment ${lotNamePieces.interment}`);
|
||||
let lotName = `${lotNamePieces.cemetery}-`;
|
||||
if (lotNamePieces.block !== '') {
|
||||
lotName += `B${lotNamePieces.block}-`;
|
||||
}
|
||||
if (lotNamePieces.range1 !== '0' || lotNamePieces.range2 !== '') {
|
||||
lotName += `R${lotNamePieces.range1 === '0' ? '' : lotNamePieces.range1}${lotNamePieces.range2}-`;
|
||||
}
|
||||
if (lotNamePieces.lot1 !== '0' || lotNamePieces.lot2 === '') {
|
||||
lotName += `L${lotNamePieces.lot1}${lotNamePieces.lot2}-`;
|
||||
}
|
||||
lotName += `G${lotNamePieces.grave1}${lotNamePieces.grave2}, Interment ${lotNamePieces.interment}`;
|
||||
return lotName;
|
||||
}
|
||||
export function getFuneralHomeLotOccupancyOccupantData(funeralHomeKey) {
|
||||
switch (funeralHomeKey) {
|
||||
|
|
|
|||
|
|
@ -13,22 +13,25 @@ export function buildLotName(lotNamePieces: {
|
|||
grave2: string
|
||||
interment: string
|
||||
}): string {
|
||||
return (
|
||||
lotNamePieces.cemetery +
|
||||
'-' +
|
||||
(lotNamePieces.block === '' ? '' : `B${lotNamePieces.block}-`) +
|
||||
(lotNamePieces.range1 === '0' && lotNamePieces.range2 === ''
|
||||
? ''
|
||||
: `R${lotNamePieces.range1 === '0' ? '' : lotNamePieces.range1}${
|
||||
let lotName = `${lotNamePieces.cemetery}-`
|
||||
|
||||
if (lotNamePieces.block !== '') {
|
||||
lotName += `B${lotNamePieces.block}-`
|
||||
}
|
||||
|
||||
if (lotNamePieces.range1 !== '0' || lotNamePieces.range2 !== '') {
|
||||
lotName += `R${lotNamePieces.range1 === '0' ? '' : lotNamePieces.range1}${
|
||||
lotNamePieces.range2
|
||||
}-`) +
|
||||
(lotNamePieces.lot1 === '0' && lotNamePieces.lot2 === ''
|
||||
? ''
|
||||
: `L${lotNamePieces.lot1}${lotNamePieces.lot2}-`) +
|
||||
`G${lotNamePieces.grave1}${lotNamePieces.grave2}` +
|
||||
', ' +
|
||||
`Interment ${lotNamePieces.interment}`
|
||||
)
|
||||
}-`
|
||||
}
|
||||
|
||||
if (lotNamePieces.lot1 !== '0' || lotNamePieces.lot2 === '') {
|
||||
lotName += `L${lotNamePieces.lot1}${lotNamePieces.lot2}-`
|
||||
}
|
||||
|
||||
lotName += `G${lotNamePieces.grave1}${lotNamePieces.grave2}, Interment ${lotNamePieces.interment}`
|
||||
|
||||
return lotName
|
||||
}
|
||||
|
||||
export function getFuneralHomeLotOccupancyOccupantData(
|
||||
|
|
|
|||
Loading…
Reference in New Issue