linting
parent
c5ef5cbeba
commit
b10fbde530
4
app.js
4
app.js
|
|
@ -14,7 +14,7 @@ import * as permissionHandlers from './handlers/permissions.js';
|
|||
import { getSafeRedirectURL } from './helpers/functions.authentication.js';
|
||||
import * as configFunctions from './helpers/functions.config.js';
|
||||
import * as printFunctions from './helpers/functions.print.js';
|
||||
import * as databaseInitializer from './helpers/initializer.database.js';
|
||||
import { initializeDatabase } from './helpers/initializer.database.js';
|
||||
import routerAdmin from './routes/admin.js';
|
||||
import routerApi from './routes/api.js';
|
||||
import routerDashboard from './routes/dashboard.js';
|
||||
|
|
@ -27,7 +27,7 @@ import routerReports from './routes/reports.js';
|
|||
import routerWorkOrders from './routes/workOrders.js';
|
||||
import { version } from './version.js';
|
||||
const debug = Debug(`lot-occupancy-system:app:${process.pid}`);
|
||||
databaseInitializer.initializeDatabase();
|
||||
initializeDatabase();
|
||||
const _dirname = '.';
|
||||
export const app = express();
|
||||
app.disable('X-Powered-By');
|
||||
|
|
|
|||
4
app.ts
4
app.ts
|
|
@ -16,7 +16,7 @@ import * as permissionHandlers from './handlers/permissions.js'
|
|||
import { getSafeRedirectURL } from './helpers/functions.authentication.js'
|
||||
import * as configFunctions from './helpers/functions.config.js'
|
||||
import * as printFunctions from './helpers/functions.print.js'
|
||||
import * as databaseInitializer from './helpers/initializer.database.js'
|
||||
import { initializeDatabase } from './helpers/initializer.database.js'
|
||||
import routerAdmin from './routes/admin.js'
|
||||
import routerApi from './routes/api.js'
|
||||
import routerDashboard from './routes/dashboard.js'
|
||||
|
|
@ -35,7 +35,7 @@ const debug = Debug(`lot-occupancy-system:app:${process.pid}`)
|
|||
* INITIALIZE THE DATABASE
|
||||
*/
|
||||
|
||||
databaseInitializer.initializeDatabase()
|
||||
initializeDatabase()
|
||||
|
||||
/*
|
||||
* INITIALIZE APP
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as dateTimeFunctions from '@cityssm/utils-datetime';
|
||||
import { dateToInteger, dateToTimeInteger } from '@cityssm/utils-datetime';
|
||||
import { acquireConnection } from './pool.js';
|
||||
export default async function addLotComment(lotCommentForm, user) {
|
||||
const database = await acquireConnection();
|
||||
|
|
@ -10,7 +10,7 @@ export default async function addLotComment(lotCommentForm, user) {
|
|||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||
.run(lotCommentForm.lotId, dateTimeFunctions.dateToInteger(rightNow), dateTimeFunctions.dateToTimeInteger(rightNow), lotCommentForm.lotComment, user.userName, rightNow.getTime(), user.userName, rightNow.getTime());
|
||||
.run(lotCommentForm.lotId, dateToInteger(rightNow), dateToTimeInteger(rightNow), lotCommentForm.lotComment, user.userName, rightNow.getTime(), user.userName, rightNow.getTime());
|
||||
database.release();
|
||||
return result.lastInsertRowid;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as dateTimeFunctions from '@cityssm/utils-datetime'
|
||||
import { dateToInteger, dateToTimeInteger } from '@cityssm/utils-datetime'
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
|
|
@ -26,8 +26,8 @@ export default async function addLotComment(
|
|||
)
|
||||
.run(
|
||||
lotCommentForm.lotId,
|
||||
dateTimeFunctions.dateToInteger(rightNow),
|
||||
dateTimeFunctions.dateToTimeInteger(rightNow),
|
||||
dateToInteger(rightNow),
|
||||
dateToTimeInteger(rightNow),
|
||||
lotCommentForm.lotComment,
|
||||
user.userName,
|
||||
rightNow.getTime(),
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import * as dateTimeFunctions from '@cityssm/utils-datetime';
|
||||
import { dateStringToInteger } from '@cityssm/utils-datetime';
|
||||
import addLotOccupancyOccupant from './addLotOccupancyOccupant.js';
|
||||
import addOrUpdateLotOccupancyField from './addOrUpdateLotOccupancyField.js';
|
||||
import { acquireConnection } from './pool.js';
|
||||
export default async function addLotOccupancy(lotOccupancyForm, user, connectedDatabase) {
|
||||
const database = connectedDatabase ?? (await acquireConnection());
|
||||
const rightNowMillis = Date.now();
|
||||
const occupancyStartDate = dateTimeFunctions.dateStringToInteger(lotOccupancyForm.occupancyStartDateString);
|
||||
const occupancyStartDate = dateStringToInteger(lotOccupancyForm.occupancyStartDateString);
|
||||
if (occupancyStartDate <= 0) {
|
||||
console.error(lotOccupancyForm);
|
||||
}
|
||||
|
|
@ -18,7 +18,7 @@ export default async function addLotOccupancy(lotOccupancyForm, user, connectedD
|
|||
values (?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||
.run(lotOccupancyForm.occupancyTypeId, lotOccupancyForm.lotId === '' ? undefined : lotOccupancyForm.lotId, occupancyStartDate, lotOccupancyForm.occupancyEndDateString === ''
|
||||
? undefined
|
||||
: dateTimeFunctions.dateStringToInteger(lotOccupancyForm.occupancyEndDateString), user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
: dateStringToInteger(lotOccupancyForm.occupancyEndDateString), user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
const lotOccupancyId = result.lastInsertRowid;
|
||||
const occupancyTypeFieldIds = (lotOccupancyForm.occupancyTypeFieldIds ?? '').split(',');
|
||||
for (const occupancyTypeFieldId of occupancyTypeFieldIds) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as dateTimeFunctions from '@cityssm/utils-datetime'
|
||||
import { type DateString, dateStringToInteger } from '@cityssm/utils-datetime'
|
||||
import type { PoolConnection } from 'better-sqlite-pool'
|
||||
|
||||
import addLotOccupancyOccupant from './addLotOccupancyOccupant.js'
|
||||
|
|
@ -37,8 +37,8 @@ export default async function addLotOccupancy(
|
|||
|
||||
const rightNowMillis = Date.now()
|
||||
|
||||
const occupancyStartDate = dateTimeFunctions.dateStringToInteger(
|
||||
lotOccupancyForm.occupancyStartDateString as dateTimeFunctions.DateString
|
||||
const occupancyStartDate = dateStringToInteger(
|
||||
lotOccupancyForm.occupancyStartDateString as DateString
|
||||
)
|
||||
|
||||
if (occupancyStartDate <= 0) {
|
||||
|
|
@ -60,8 +60,8 @@ export default async function addLotOccupancy(
|
|||
occupancyStartDate,
|
||||
lotOccupancyForm.occupancyEndDateString === ''
|
||||
? undefined
|
||||
: dateTimeFunctions.dateStringToInteger(
|
||||
lotOccupancyForm.occupancyEndDateString as dateTimeFunctions.DateString
|
||||
: dateStringToInteger(
|
||||
lotOccupancyForm.occupancyEndDateString as DateString
|
||||
),
|
||||
user.userName,
|
||||
rightNowMillis,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as dateTimeFunctions from '@cityssm/utils-datetime';
|
||||
import { dateToInteger, dateToTimeInteger } from '@cityssm/utils-datetime';
|
||||
import { acquireConnection } from './pool.js';
|
||||
export default async function addWorkOrderComment(workOrderCommentForm, user) {
|
||||
const database = await acquireConnection();
|
||||
|
|
@ -11,7 +11,7 @@ export default async function addWorkOrderComment(workOrderCommentForm, user) {
|
|||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||
.run(workOrderCommentForm.workOrderId, dateTimeFunctions.dateToInteger(rightNow), dateTimeFunctions.dateToTimeInteger(rightNow), workOrderCommentForm.workOrderComment, user.userName, rightNow.getTime(), user.userName, rightNow.getTime());
|
||||
.run(workOrderCommentForm.workOrderId, dateToInteger(rightNow), dateToTimeInteger(rightNow), workOrderCommentForm.workOrderComment, user.userName, rightNow.getTime(), user.userName, rightNow.getTime());
|
||||
database.release();
|
||||
return result.lastInsertRowid;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as dateTimeFunctions from '@cityssm/utils-datetime'
|
||||
import { dateToInteger, dateToTimeInteger } from '@cityssm/utils-datetime'
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
|
|
@ -27,8 +27,8 @@ export default async function addWorkOrderComment(
|
|||
)
|
||||
.run(
|
||||
workOrderCommentForm.workOrderId,
|
||||
dateTimeFunctions.dateToInteger(rightNow),
|
||||
dateTimeFunctions.dateToTimeInteger(rightNow),
|
||||
dateToInteger(rightNow),
|
||||
dateToTimeInteger(rightNow),
|
||||
workOrderCommentForm.workOrderComment,
|
||||
user.userName,
|
||||
rightNow.getTime(),
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as dateTimeFunctions from '@cityssm/utils-datetime';
|
||||
import { dateIntegerToString, dateStringToInteger, dateToInteger, timeIntegerToString } from '@cityssm/utils-datetime';
|
||||
import camelCase from 'camelcase';
|
||||
import { getConfigProperty } from '../helpers/functions.config.js';
|
||||
import { acquireConnection } from './pool.js';
|
||||
|
|
@ -132,7 +132,7 @@ export default async function getReportData(reportName, reportParameters = {}) {
|
|||
where o.recordDelete_timeMillis is null
|
||||
and (o.occupancyEndDate is null or o.occupancyEndDate >= ?)
|
||||
and l.mapId = ?`;
|
||||
sqlParameters.push(dateTimeFunctions.dateToInteger(new Date()), reportParameters.mapId);
|
||||
sqlParameters.push(dateToInteger(new Date()), reportParameters.mapId);
|
||||
break;
|
||||
}
|
||||
case 'lotOccupancyComments-all': {
|
||||
|
|
@ -184,7 +184,7 @@ export default async function getReportData(reportName, reportParameters = {}) {
|
|||
from LotOccupancyTransactions t
|
||||
where t.recordDelete_timeMillis is null
|
||||
and t.transactionDate = ?`;
|
||||
sqlParameters.push(dateTimeFunctions.dateStringToInteger(reportParameters.transactionDateString));
|
||||
sqlParameters.push(dateStringToInteger(reportParameters.transactionDateString));
|
||||
break;
|
||||
}
|
||||
case 'workOrders-all': {
|
||||
|
|
@ -281,8 +281,8 @@ export default async function getReportData(reportName, reportParameters = {}) {
|
|||
}
|
||||
}
|
||||
const database = await acquireConnection();
|
||||
database.function('userFn_dateIntegerToString', dateTimeFunctions.dateIntegerToString);
|
||||
database.function('userFn_timeIntegerToString', dateTimeFunctions.timeIntegerToString);
|
||||
database.function('userFn_dateIntegerToString', dateIntegerToString);
|
||||
database.function('userFn_timeIntegerToString', timeIntegerToString);
|
||||
const rows = database.prepare(sql).all(sqlParameters);
|
||||
database.release();
|
||||
return rows;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,13 @@
|
|||
// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair
|
||||
/* eslint-disable no-case-declarations */
|
||||
|
||||
import * as dateTimeFunctions from '@cityssm/utils-datetime'
|
||||
import {
|
||||
type DateString,
|
||||
dateIntegerToString,
|
||||
dateStringToInteger,
|
||||
dateToInteger,
|
||||
timeIntegerToString
|
||||
} from '@cityssm/utils-datetime'
|
||||
import camelCase from 'camelcase'
|
||||
|
||||
import { getConfigProperty } from '../helpers/functions.config.js'
|
||||
|
|
@ -166,10 +172,7 @@ export default async function getReportData(
|
|||
and (o.occupancyEndDate is null or o.occupancyEndDate >= ?)
|
||||
and l.mapId = ?`
|
||||
|
||||
sqlParameters.push(
|
||||
dateTimeFunctions.dateToInteger(new Date()),
|
||||
reportParameters.mapId
|
||||
)
|
||||
sqlParameters.push(dateToInteger(new Date()), reportParameters.mapId)
|
||||
|
||||
break
|
||||
}
|
||||
|
|
@ -231,8 +234,8 @@ export default async function getReportData(
|
|||
and t.transactionDate = ?`
|
||||
|
||||
sqlParameters.push(
|
||||
dateTimeFunctions.dateStringToInteger(
|
||||
reportParameters.transactionDateString as dateTimeFunctions.DateString
|
||||
dateStringToInteger(
|
||||
reportParameters.transactionDateString as DateString
|
||||
)
|
||||
)
|
||||
break
|
||||
|
|
@ -350,14 +353,8 @@ export default async function getReportData(
|
|||
|
||||
const database = await acquireConnection()
|
||||
|
||||
database.function(
|
||||
'userFn_dateIntegerToString',
|
||||
dateTimeFunctions.dateIntegerToString
|
||||
)
|
||||
database.function(
|
||||
'userFn_timeIntegerToString',
|
||||
dateTimeFunctions.timeIntegerToString
|
||||
)
|
||||
database.function('userFn_dateIntegerToString', dateIntegerToString)
|
||||
database.function('userFn_timeIntegerToString', timeIntegerToString)
|
||||
|
||||
const rows = database.prepare(sql).all(sqlParameters)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair
|
||||
/* eslint-disable n/no-unpublished-import */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return, n/no-unpublished-import */
|
||||
|
||||
import gulp from 'gulp'
|
||||
import changed from 'gulp-changed'
|
||||
|
|
@ -22,6 +22,7 @@ function publicSCSSFunction(): NodeJS.ReadWriteStream {
|
|||
.pipe(
|
||||
sass({ outputStyle: 'compressed', includePaths: ['node_modules'] }).on(
|
||||
'error',
|
||||
// eslint-disable-next-line @typescript-eslint/unbound-method
|
||||
sass.logError
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { getConfigProperty } from '../helpers/functions.config.js';
|
||||
import * as userFunctions from '../helpers/functions.user.js';
|
||||
import { apiKeyIsValid, userCanUpdate, userIsAdmin } from '../helpers/functions.user.js';
|
||||
const urlPrefix = getConfigProperty('reverseProxy.urlPrefix');
|
||||
const forbiddenStatus = 403;
|
||||
const forbiddenJSON = {
|
||||
|
|
@ -8,35 +8,35 @@ const forbiddenJSON = {
|
|||
};
|
||||
const forbiddenRedirectURL = `${urlPrefix}/dashboard/?error=accessDenied`;
|
||||
export function adminGetHandler(request, response, next) {
|
||||
if (userFunctions.userIsAdmin(request)) {
|
||||
if (userIsAdmin(request)) {
|
||||
next();
|
||||
return;
|
||||
}
|
||||
response.redirect(forbiddenRedirectURL);
|
||||
}
|
||||
export function adminPostHandler(request, response, next) {
|
||||
if (userFunctions.userIsAdmin(request)) {
|
||||
if (userIsAdmin(request)) {
|
||||
next();
|
||||
return;
|
||||
}
|
||||
response.status(forbiddenStatus).json(forbiddenJSON);
|
||||
}
|
||||
export function updateGetHandler(request, response, next) {
|
||||
if (userFunctions.userCanUpdate(request)) {
|
||||
if (userCanUpdate(request)) {
|
||||
next();
|
||||
return;
|
||||
}
|
||||
response.redirect(forbiddenRedirectURL);
|
||||
}
|
||||
export function updatePostHandler(request, response, next) {
|
||||
if (userFunctions.userCanUpdate(request)) {
|
||||
if (userCanUpdate(request)) {
|
||||
next();
|
||||
return;
|
||||
}
|
||||
response.status(forbiddenStatus).json(forbiddenJSON);
|
||||
}
|
||||
export async function apiGetHandler(request, response, next) {
|
||||
if (await userFunctions.apiKeyIsValid(request)) {
|
||||
if (await apiKeyIsValid(request)) {
|
||||
next();
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
import type { NextFunction, Request, Response } from 'express'
|
||||
|
||||
import { getConfigProperty } from '../helpers/functions.config.js'
|
||||
import * as userFunctions from '../helpers/functions.user.js'
|
||||
import {
|
||||
apiKeyIsValid,
|
||||
userCanUpdate,
|
||||
userIsAdmin
|
||||
} from '../helpers/functions.user.js'
|
||||
|
||||
const urlPrefix = getConfigProperty('reverseProxy.urlPrefix')
|
||||
|
||||
|
|
@ -19,7 +23,7 @@ export function adminGetHandler(
|
|||
response: Response,
|
||||
next: NextFunction
|
||||
): void {
|
||||
if (userFunctions.userIsAdmin(request)) {
|
||||
if (userIsAdmin(request)) {
|
||||
next()
|
||||
return
|
||||
}
|
||||
|
|
@ -32,7 +36,7 @@ export function adminPostHandler(
|
|||
response: Response,
|
||||
next: NextFunction
|
||||
): void {
|
||||
if (userFunctions.userIsAdmin(request)) {
|
||||
if (userIsAdmin(request)) {
|
||||
next()
|
||||
return
|
||||
}
|
||||
|
|
@ -45,7 +49,7 @@ export function updateGetHandler(
|
|||
response: Response,
|
||||
next: NextFunction
|
||||
): void {
|
||||
if (userFunctions.userCanUpdate(request)) {
|
||||
if (userCanUpdate(request)) {
|
||||
next()
|
||||
return
|
||||
}
|
||||
|
|
@ -58,7 +62,7 @@ export function updatePostHandler(
|
|||
response: Response,
|
||||
next: NextFunction
|
||||
): void {
|
||||
if (userFunctions.userCanUpdate(request)) {
|
||||
if (userCanUpdate(request)) {
|
||||
next()
|
||||
return
|
||||
}
|
||||
|
|
@ -71,7 +75,7 @@ export async function apiGetHandler(
|
|||
response: Response,
|
||||
next: NextFunction
|
||||
): Promise<void> {
|
||||
if (await userFunctions.apiKeyIsValid(request)) {
|
||||
if (await apiKeyIsValid(request)) {
|
||||
next()
|
||||
} else {
|
||||
response.redirect(`${urlPrefix}/login`)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as dateTimeFunctions from '@cityssm/utils-datetime';
|
||||
import { dateToString } from '@cityssm/utils-datetime';
|
||||
import getMaps from '../../database/getMaps.js';
|
||||
import { getLotStatuses, getLotTypes } from '../../helpers/functions.cache.js';
|
||||
export default async function handler(_request, response) {
|
||||
|
|
@ -8,7 +8,7 @@ export default async function handler(_request, response) {
|
|||
const lotStatuses = await getLotStatuses();
|
||||
response.render('report-search', {
|
||||
headTitle: 'Reports',
|
||||
todayDateString: dateTimeFunctions.dateToString(rightNow),
|
||||
todayDateString: dateToString(rightNow),
|
||||
maps,
|
||||
lotTypes,
|
||||
lotStatuses
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as dateTimeFunctions from '@cityssm/utils-datetime'
|
||||
import { dateToString } from '@cityssm/utils-datetime'
|
||||
import type { Request, Response } from 'express'
|
||||
|
||||
import getMaps from '../../database/getMaps.js'
|
||||
|
|
@ -16,7 +16,7 @@ export default async function handler(
|
|||
|
||||
response.render('report-search', {
|
||||
headTitle: 'Reports',
|
||||
todayDateString: dateTimeFunctions.dateToString(rightNow),
|
||||
todayDateString: dateToString(rightNow),
|
||||
maps,
|
||||
lotTypes,
|
||||
lotStatuses
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import type * as recordTypes from '../types/recordTypes';
|
||||
export declare function filterOccupantsByLotOccupantType(lotOccupancy: recordTypes.LotOccupancy, lotOccupantType: string): recordTypes.LotOccupancyOccupant[];
|
||||
export declare function getFieldValueByOccupancyTypeField(lotOccupancy: recordTypes.LotOccupancy, occupancyTypeField: string): string | undefined;
|
||||
export declare function getFeesByFeeCategory(lotOccupancy: recordTypes.LotOccupancy, feeCategory: string, feeCategoryContains?: boolean): recordTypes.LotOccupancyFee[];
|
||||
export declare function getTransactionTotal(lotOccupancy: recordTypes.LotOccupancy): number;
|
||||
import type { LotOccupancy, LotOccupancyFee, LotOccupancyOccupant } from '../types/recordTypes';
|
||||
export declare function filterOccupantsByLotOccupantType(lotOccupancy: LotOccupancy, lotOccupantType: string): LotOccupancyOccupant[];
|
||||
export declare function getFieldValueByOccupancyTypeField(lotOccupancy: LotOccupancy, occupancyTypeField: string): string | undefined;
|
||||
export declare function getFeesByFeeCategory(lotOccupancy: LotOccupancy, feeCategory: string, feeCategoryContains?: boolean): LotOccupancyFee[];
|
||||
export declare function getTransactionTotal(lotOccupancy: LotOccupancy): number;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import type * as recordTypes from '../types/recordTypes'
|
||||
import type { LotOccupancy, LotOccupancyFee, LotOccupancyOccupant } from '../types/recordTypes'
|
||||
|
||||
export function filterOccupantsByLotOccupantType(
|
||||
lotOccupancy: recordTypes.LotOccupancy,
|
||||
lotOccupancy: LotOccupancy,
|
||||
lotOccupantType: string
|
||||
): recordTypes.LotOccupancyOccupant[] {
|
||||
): LotOccupancyOccupant[] {
|
||||
const lotOccupantTypeLowerCase = lotOccupantType.toLowerCase()
|
||||
|
||||
return (lotOccupancy.lotOccupancyOccupants ?? []).filter(
|
||||
|
|
@ -17,7 +17,7 @@ export function filterOccupantsByLotOccupantType(
|
|||
}
|
||||
|
||||
export function getFieldValueByOccupancyTypeField(
|
||||
lotOccupancy: recordTypes.LotOccupancy,
|
||||
lotOccupancy: LotOccupancy,
|
||||
occupancyTypeField: string
|
||||
): string | undefined {
|
||||
const occupancyTypeFieldLowerCase = occupancyTypeField.toLowerCase()
|
||||
|
|
@ -39,10 +39,10 @@ export function getFieldValueByOccupancyTypeField(
|
|||
}
|
||||
|
||||
export function getFeesByFeeCategory(
|
||||
lotOccupancy: recordTypes.LotOccupancy,
|
||||
lotOccupancy: LotOccupancy,
|
||||
feeCategory: string,
|
||||
feeCategoryContains = false
|
||||
): recordTypes.LotOccupancyFee[] {
|
||||
): LotOccupancyFee[] {
|
||||
const feeCategoryLowerCase = feeCategory.toLowerCase()
|
||||
|
||||
return (lotOccupancy.lotOccupancyFees ?? []).filter((possibleFee) => {
|
||||
|
|
@ -56,7 +56,7 @@ export function getFeesByFeeCategory(
|
|||
}
|
||||
|
||||
export function getTransactionTotal(
|
||||
lotOccupancy: recordTypes.LotOccupancy
|
||||
lotOccupancy: LotOccupancy
|
||||
): number {
|
||||
let transactionTotal = 0
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { getUserNameFromApiKey } from './functions.api.js';
|
||||
import * as configFunctions from './functions.config.js';
|
||||
import { getConfigProperty } from './functions.config.js';
|
||||
export function userIsAdmin(request) {
|
||||
return request.session?.user?.userProperties?.isAdmin ?? false;
|
||||
}
|
||||
|
|
@ -15,9 +15,7 @@ export async function apiKeyIsValid(request) {
|
|||
if (userName === undefined) {
|
||||
return false;
|
||||
}
|
||||
return configFunctions
|
||||
.getConfigProperty('users.canLogin')
|
||||
.some((currentUserName) => {
|
||||
return getConfigProperty('users.canLogin').some((currentUserName) => {
|
||||
return userName === currentUserName.toLowerCase();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { getUserNameFromApiKey } from './functions.api.js'
|
||||
import * as configFunctions from './functions.config.js'
|
||||
import { getConfigProperty } from './functions.config.js'
|
||||
|
||||
export interface UserRequest {
|
||||
session?: {
|
||||
|
|
@ -34,9 +34,7 @@ export async function apiKeyIsValid(request: APIRequest): Promise<boolean> {
|
|||
return false
|
||||
}
|
||||
|
||||
return configFunctions
|
||||
.getConfigProperty('users.canLogin')
|
||||
.some((currentUserName) => {
|
||||
return getConfigProperty('users.canLogin').some((currentUserName) => {
|
||||
return userName === currentUserName.toLowerCase()
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ const user = {
|
|||
}
|
||||
};
|
||||
export async function initializeCemeteryDatabase() {
|
||||
debug('Checking for ' + databasePath + '...');
|
||||
debug(`Checking for ${databasePath}...`);
|
||||
const databaseInitialized = initializeDatabase();
|
||||
if (!databaseInitialized) {
|
||||
debug('Database already created.\n' +
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ export async function initializeCemeteryDatabase(): Promise<boolean> {
|
|||
/*
|
||||
* Ensure database does not already exist
|
||||
*/
|
||||
debug('Checking for ' + databasePath + '...')
|
||||
debug(`Checking for ${databasePath}...`)
|
||||
|
||||
const databaseInitialized = initializeDatabase()
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import Debug from 'debug';
|
|||
import { Router } from 'express';
|
||||
import { useTestDatabases } from '../data/databasePaths.js';
|
||||
import { getApiKey } from '../helpers/functions.api.js';
|
||||
import * as authenticationFunctions from '../helpers/functions.authentication.js';
|
||||
import { authenticate, getSafeRedirectURL } from '../helpers/functions.authentication.js';
|
||||
import { getConfigProperty } from '../helpers/functions.config.js';
|
||||
const debug = Debug('lot-occupancy-system:login');
|
||||
export const router = Router();
|
||||
|
|
@ -10,7 +10,7 @@ function getHandler(request, response) {
|
|||
const sessionCookieName = getConfigProperty('session.cookieName');
|
||||
if (request.session.user !== undefined &&
|
||||
request.cookies[sessionCookieName] !== undefined) {
|
||||
const redirectURL = authenticationFunctions.getSafeRedirectURL((request.query.redirect ?? ''));
|
||||
const redirectURL = getSafeRedirectURL((request.query.redirect ?? ''));
|
||||
response.redirect(redirectURL);
|
||||
}
|
||||
else {
|
||||
|
|
@ -26,7 +26,7 @@ async function postHandler(request, response) {
|
|||
const userName = (typeof request.body.userName === 'string' ? request.body.userName : '');
|
||||
const passwordPlain = (typeof request.body.password === 'string' ? request.body.password : '');
|
||||
const unsafeRedirectURL = request.body.redirect;
|
||||
const redirectURL = authenticationFunctions.getSafeRedirectURL(typeof unsafeRedirectURL === 'string' ? unsafeRedirectURL : '');
|
||||
const redirectURL = getSafeRedirectURL(typeof unsafeRedirectURL === 'string' ? unsafeRedirectURL : '');
|
||||
let isAuthenticated = false;
|
||||
if (userName.startsWith('*')) {
|
||||
if (useTestDatabases && userName === passwordPlain) {
|
||||
|
|
@ -37,7 +37,7 @@ async function postHandler(request, response) {
|
|||
}
|
||||
}
|
||||
else if (userName !== '' && passwordPlain !== '') {
|
||||
isAuthenticated = await authenticationFunctions.authenticate(userName, passwordPlain);
|
||||
isAuthenticated = await authenticate(userName, passwordPlain);
|
||||
}
|
||||
let userObject;
|
||||
if (isAuthenticated) {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,10 @@ import {
|
|||
|
||||
import { useTestDatabases } from '../data/databasePaths.js'
|
||||
import { getApiKey } from '../helpers/functions.api.js'
|
||||
import * as authenticationFunctions from '../helpers/functions.authentication.js'
|
||||
import {
|
||||
authenticate,
|
||||
getSafeRedirectURL
|
||||
} from '../helpers/functions.authentication.js'
|
||||
import { getConfigProperty } from '../helpers/functions.config.js'
|
||||
|
||||
const debug = Debug('lot-occupancy-system:login')
|
||||
|
|
@ -22,7 +25,7 @@ function getHandler(request: Request, response: Response): void {
|
|||
request.session.user !== undefined &&
|
||||
request.cookies[sessionCookieName] !== undefined
|
||||
) {
|
||||
const redirectURL = authenticationFunctions.getSafeRedirectURL(
|
||||
const redirectURL = getSafeRedirectURL(
|
||||
(request.query.redirect ?? '') as string
|
||||
)
|
||||
|
||||
|
|
@ -51,7 +54,7 @@ async function postHandler(
|
|||
|
||||
const unsafeRedirectURL = request.body.redirect
|
||||
|
||||
const redirectURL = authenticationFunctions.getSafeRedirectURL(
|
||||
const redirectURL = getSafeRedirectURL(
|
||||
typeof unsafeRedirectURL === 'string' ? unsafeRedirectURL : ''
|
||||
)
|
||||
|
||||
|
|
@ -66,10 +69,7 @@ async function postHandler(
|
|||
}
|
||||
}
|
||||
} else if (userName !== '' && passwordPlain !== '') {
|
||||
isAuthenticated = await authenticationFunctions.authenticate(
|
||||
userName,
|
||||
passwordPlain
|
||||
)
|
||||
isAuthenticated = await authenticate(userName, passwordPlain)
|
||||
}
|
||||
|
||||
let userObject: User | undefined
|
||||
|
|
|
|||
|
|
@ -24,34 +24,34 @@ import handler_doUpdateLotOccupancyComment from '../handlers/lotOccupancies-post
|
|||
import handler_doUpdateLotOccupancyFeeQuantity from '../handlers/lotOccupancies-post/doUpdateLotOccupancyFeeQuantity.js';
|
||||
import handler_doUpdateLotOccupancyOccupant from '../handlers/lotOccupancies-post/doUpdateLotOccupancyOccupant.js';
|
||||
import handler_doUpdateLotOccupancyTransaction from '../handlers/lotOccupancies-post/doUpdateLotOccupancyTransaction.js';
|
||||
import * as permissionHandlers from '../handlers/permissions.js';
|
||||
import { updateGetHandler, updatePostHandler } from '../handlers/permissions.js';
|
||||
import { getConfigProperty } from '../helpers/functions.config.js';
|
||||
export const router = Router();
|
||||
router.get('/', handler_search);
|
||||
router.post('/doSearchLotOccupancies', handler_doSearchLotOccupancies);
|
||||
router.get('/new', permissionHandlers.updateGetHandler, handler_new);
|
||||
router.post('/doGetOccupancyTypeFields', permissionHandlers.updatePostHandler, handler_doGetOccupancyTypeFields);
|
||||
router.post('/doCreateLotOccupancy', permissionHandlers.updatePostHandler, handler_doCreateLotOccupancy);
|
||||
router.get('/new', updateGetHandler, handler_new);
|
||||
router.post('/doGetOccupancyTypeFields', updatePostHandler, handler_doGetOccupancyTypeFields);
|
||||
router.post('/doCreateLotOccupancy', updatePostHandler, handler_doCreateLotOccupancy);
|
||||
router.get('/:lotOccupancyId', handler_view);
|
||||
router.get('/:lotOccupancyId/edit', permissionHandlers.updateGetHandler, handler_edit);
|
||||
router.post('/doUpdateLotOccupancy', permissionHandlers.updatePostHandler, handler_doUpdateLotOccupancy);
|
||||
router.post('/doCopyLotOccupancy', permissionHandlers.updatePostHandler, handler_doCopyLotOccupancy);
|
||||
router.post('/doDeleteLotOccupancy', permissionHandlers.updatePostHandler, handler_doDeleteLotOccupancy);
|
||||
router.post('/doSearchPastOccupants', permissionHandlers.updatePostHandler, handler_doSearchPastOccupants);
|
||||
router.post('/doAddLotOccupancyOccupant', permissionHandlers.updatePostHandler, handler_doAddLotOccupancyOccupant);
|
||||
router.post('/doUpdateLotOccupancyOccupant', permissionHandlers.updatePostHandler, handler_doUpdateLotOccupancyOccupant);
|
||||
router.post('/doDeleteLotOccupancyOccupant', permissionHandlers.updatePostHandler, handler_doDeleteLotOccupancyOccupant);
|
||||
router.post('/doAddLotOccupancyComment', permissionHandlers.updatePostHandler, handler_doAddLotOccupancyComment);
|
||||
router.post('/doUpdateLotOccupancyComment', permissionHandlers.updatePostHandler, handler_doUpdateLotOccupancyComment);
|
||||
router.post('/doDeleteLotOccupancyComment', permissionHandlers.updatePostHandler, handler_doDeleteLotOccupancyComment);
|
||||
router.post('/doGetFees', permissionHandlers.updatePostHandler, handler_doGetFees);
|
||||
router.post('/doAddLotOccupancyFee', permissionHandlers.updatePostHandler, handler_doAddLotOccupancyFee);
|
||||
router.post('/doUpdateLotOccupancyFeeQuantity', permissionHandlers.updatePostHandler, handler_doUpdateLotOccupancyFeeQuantity);
|
||||
router.post('/doDeleteLotOccupancyFee', permissionHandlers.updatePostHandler, handler_doDeleteLotOccupancyFee);
|
||||
router.get('/:lotOccupancyId/edit', updateGetHandler, handler_edit);
|
||||
router.post('/doUpdateLotOccupancy', updatePostHandler, handler_doUpdateLotOccupancy);
|
||||
router.post('/doCopyLotOccupancy', updatePostHandler, handler_doCopyLotOccupancy);
|
||||
router.post('/doDeleteLotOccupancy', updatePostHandler, handler_doDeleteLotOccupancy);
|
||||
router.post('/doSearchPastOccupants', updatePostHandler, handler_doSearchPastOccupants);
|
||||
router.post('/doAddLotOccupancyOccupant', updatePostHandler, handler_doAddLotOccupancyOccupant);
|
||||
router.post('/doUpdateLotOccupancyOccupant', updatePostHandler, handler_doUpdateLotOccupancyOccupant);
|
||||
router.post('/doDeleteLotOccupancyOccupant', updatePostHandler, handler_doDeleteLotOccupancyOccupant);
|
||||
router.post('/doAddLotOccupancyComment', updatePostHandler, handler_doAddLotOccupancyComment);
|
||||
router.post('/doUpdateLotOccupancyComment', updatePostHandler, handler_doUpdateLotOccupancyComment);
|
||||
router.post('/doDeleteLotOccupancyComment', updatePostHandler, handler_doDeleteLotOccupancyComment);
|
||||
router.post('/doGetFees', updatePostHandler, handler_doGetFees);
|
||||
router.post('/doAddLotOccupancyFee', updatePostHandler, handler_doAddLotOccupancyFee);
|
||||
router.post('/doUpdateLotOccupancyFeeQuantity', updatePostHandler, handler_doUpdateLotOccupancyFeeQuantity);
|
||||
router.post('/doDeleteLotOccupancyFee', updatePostHandler, handler_doDeleteLotOccupancyFee);
|
||||
if (getConfigProperty('settings.dynamicsGP.integrationIsEnabled')) {
|
||||
router.post('/doGetDynamicsGPDocument', permissionHandlers.updatePostHandler, handler_doGetDynamicsGPDocument);
|
||||
router.post('/doGetDynamicsGPDocument', updatePostHandler, handler_doGetDynamicsGPDocument);
|
||||
}
|
||||
router.post('/doAddLotOccupancyTransaction', permissionHandlers.updatePostHandler, handler_doAddLotOccupancyTransaction);
|
||||
router.post('/doUpdateLotOccupancyTransaction', permissionHandlers.updatePostHandler, handler_doUpdateLotOccupancyTransaction);
|
||||
router.post('/doDeleteLotOccupancyTransaction', permissionHandlers.updatePostHandler, handler_doDeleteLotOccupancyTransaction);
|
||||
router.post('/doAddLotOccupancyTransaction', updatePostHandler, handler_doAddLotOccupancyTransaction);
|
||||
router.post('/doUpdateLotOccupancyTransaction', updatePostHandler, handler_doUpdateLotOccupancyTransaction);
|
||||
router.post('/doDeleteLotOccupancyTransaction', updatePostHandler, handler_doDeleteLotOccupancyTransaction);
|
||||
export default router;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import handler_doUpdateLotOccupancyComment from '../handlers/lotOccupancies-post
|
|||
import handler_doUpdateLotOccupancyFeeQuantity from '../handlers/lotOccupancies-post/doUpdateLotOccupancyFeeQuantity.js'
|
||||
import handler_doUpdateLotOccupancyOccupant from '../handlers/lotOccupancies-post/doUpdateLotOccupancyOccupant.js'
|
||||
import handler_doUpdateLotOccupancyTransaction from '../handlers/lotOccupancies-post/doUpdateLotOccupancyTransaction.js'
|
||||
import * as permissionHandlers from '../handlers/permissions.js'
|
||||
import { updateGetHandler, updatePostHandler } from '../handlers/permissions.js'
|
||||
import { getConfigProperty } from '../helpers/functions.config.js'
|
||||
|
||||
export const router = Router()
|
||||
|
|
@ -41,21 +41,17 @@ router.post(
|
|||
|
||||
// Create
|
||||
|
||||
router.get(
|
||||
'/new',
|
||||
permissionHandlers.updateGetHandler,
|
||||
handler_new as RequestHandler
|
||||
)
|
||||
router.get('/new', updateGetHandler, handler_new as RequestHandler)
|
||||
|
||||
router.post(
|
||||
'/doGetOccupancyTypeFields',
|
||||
permissionHandlers.updatePostHandler,
|
||||
updatePostHandler,
|
||||
handler_doGetOccupancyTypeFields as RequestHandler
|
||||
)
|
||||
|
||||
router.post(
|
||||
'/doCreateLotOccupancy',
|
||||
permissionHandlers.updatePostHandler,
|
||||
updatePostHandler,
|
||||
handler_doCreateLotOccupancy as RequestHandler
|
||||
)
|
||||
|
||||
|
|
@ -67,25 +63,25 @@ router.get('/:lotOccupancyId', handler_view as RequestHandler)
|
|||
|
||||
router.get(
|
||||
'/:lotOccupancyId/edit',
|
||||
permissionHandlers.updateGetHandler,
|
||||
updateGetHandler,
|
||||
handler_edit as RequestHandler
|
||||
)
|
||||
|
||||
router.post(
|
||||
'/doUpdateLotOccupancy',
|
||||
permissionHandlers.updatePostHandler,
|
||||
updatePostHandler,
|
||||
handler_doUpdateLotOccupancy as RequestHandler
|
||||
)
|
||||
|
||||
router.post(
|
||||
'/doCopyLotOccupancy',
|
||||
permissionHandlers.updatePostHandler,
|
||||
updatePostHandler,
|
||||
handler_doCopyLotOccupancy as RequestHandler
|
||||
)
|
||||
|
||||
router.post(
|
||||
'/doDeleteLotOccupancy',
|
||||
permissionHandlers.updatePostHandler,
|
||||
updatePostHandler,
|
||||
handler_doDeleteLotOccupancy as RequestHandler
|
||||
)
|
||||
|
||||
|
|
@ -93,25 +89,25 @@ router.post(
|
|||
|
||||
router.post(
|
||||
'/doSearchPastOccupants',
|
||||
permissionHandlers.updatePostHandler,
|
||||
updatePostHandler,
|
||||
handler_doSearchPastOccupants as RequestHandler
|
||||
)
|
||||
|
||||
router.post(
|
||||
'/doAddLotOccupancyOccupant',
|
||||
permissionHandlers.updatePostHandler,
|
||||
updatePostHandler,
|
||||
handler_doAddLotOccupancyOccupant as RequestHandler
|
||||
)
|
||||
|
||||
router.post(
|
||||
'/doUpdateLotOccupancyOccupant',
|
||||
permissionHandlers.updatePostHandler,
|
||||
updatePostHandler,
|
||||
handler_doUpdateLotOccupancyOccupant as RequestHandler
|
||||
)
|
||||
|
||||
router.post(
|
||||
'/doDeleteLotOccupancyOccupant',
|
||||
permissionHandlers.updatePostHandler,
|
||||
updatePostHandler,
|
||||
handler_doDeleteLotOccupancyOccupant as RequestHandler
|
||||
)
|
||||
|
||||
|
|
@ -119,19 +115,19 @@ router.post(
|
|||
|
||||
router.post(
|
||||
'/doAddLotOccupancyComment',
|
||||
permissionHandlers.updatePostHandler,
|
||||
updatePostHandler,
|
||||
handler_doAddLotOccupancyComment as RequestHandler
|
||||
)
|
||||
|
||||
router.post(
|
||||
'/doUpdateLotOccupancyComment',
|
||||
permissionHandlers.updatePostHandler,
|
||||
updatePostHandler,
|
||||
handler_doUpdateLotOccupancyComment as RequestHandler
|
||||
)
|
||||
|
||||
router.post(
|
||||
'/doDeleteLotOccupancyComment',
|
||||
permissionHandlers.updatePostHandler,
|
||||
updatePostHandler,
|
||||
handler_doDeleteLotOccupancyComment as RequestHandler
|
||||
)
|
||||
|
||||
|
|
@ -139,25 +135,25 @@ router.post(
|
|||
|
||||
router.post(
|
||||
'/doGetFees',
|
||||
permissionHandlers.updatePostHandler,
|
||||
updatePostHandler,
|
||||
handler_doGetFees as RequestHandler
|
||||
)
|
||||
|
||||
router.post(
|
||||
'/doAddLotOccupancyFee',
|
||||
permissionHandlers.updatePostHandler,
|
||||
updatePostHandler,
|
||||
handler_doAddLotOccupancyFee as RequestHandler
|
||||
)
|
||||
|
||||
router.post(
|
||||
'/doUpdateLotOccupancyFeeQuantity',
|
||||
permissionHandlers.updatePostHandler,
|
||||
updatePostHandler,
|
||||
handler_doUpdateLotOccupancyFeeQuantity as RequestHandler
|
||||
)
|
||||
|
||||
router.post(
|
||||
'/doDeleteLotOccupancyFee',
|
||||
permissionHandlers.updatePostHandler,
|
||||
updatePostHandler,
|
||||
handler_doDeleteLotOccupancyFee as RequestHandler
|
||||
)
|
||||
|
||||
|
|
@ -166,26 +162,26 @@ router.post(
|
|||
if (getConfigProperty('settings.dynamicsGP.integrationIsEnabled')) {
|
||||
router.post(
|
||||
'/doGetDynamicsGPDocument',
|
||||
permissionHandlers.updatePostHandler,
|
||||
updatePostHandler,
|
||||
handler_doGetDynamicsGPDocument as RequestHandler
|
||||
)
|
||||
}
|
||||
|
||||
router.post(
|
||||
'/doAddLotOccupancyTransaction',
|
||||
permissionHandlers.updatePostHandler,
|
||||
updatePostHandler,
|
||||
handler_doAddLotOccupancyTransaction as RequestHandler
|
||||
)
|
||||
|
||||
router.post(
|
||||
'/doUpdateLotOccupancyTransaction',
|
||||
permissionHandlers.updatePostHandler,
|
||||
updatePostHandler,
|
||||
handler_doUpdateLotOccupancyTransaction as RequestHandler
|
||||
)
|
||||
|
||||
router.post(
|
||||
'/doDeleteLotOccupancyTransaction',
|
||||
permissionHandlers.updatePostHandler,
|
||||
updatePostHandler,
|
||||
handler_doDeleteLotOccupancyTransaction as RequestHandler
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue