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