From 5276c7e962360b755863ececfd290c03567cb108 Mon Sep 17 00:00:00 2001 From: Dan Gowans Date: Thu, 19 Jan 2023 13:48:58 -0500 Subject: [PATCH] linting --- handlers/api-get/milestoneICS.ts | 8 +- helpers/functions.api.js | 8 +- helpers/functions.api.ts | 8 +- helpers/functions.authentication.js | 2 +- helpers/functions.authentication.ts | 2 +- helpers/functions.lotOccupancy.js | 6 +- helpers/functions.lotOccupancy.ts | 6 +- helpers/functions.map.js | 2 +- helpers/functions.map.ts | 2 +- helpers/functions.sqlFilters.js | 54 ++++---- helpers/functions.sqlFilters.ts | 54 ++++---- helpers/initializer.database.js | 2 +- helpers/initializer.database.ts | 2 +- helpers/lotOccupancyDB/pool.js | 3 + helpers/lotOccupancyDB/pool.ts | 4 + routes/admin.ts | 207 ++++++++++++++++++++-------- routes/api.ts | 4 +- routes/dashboard.ts | 4 +- routes/lotOccupancies.ts | 53 +++---- routes/lots.ts | 38 +++-- routes/maps.ts | 24 ++-- routes/print.ts | 6 +- routes/reports.ts | 6 +- routes/workOrders.ts | 61 ++++---- 24 files changed, 343 insertions(+), 223 deletions(-) diff --git a/handlers/api-get/milestoneICS.ts b/handlers/api-get/milestoneICS.ts index 72e41850..630afc29 100644 --- a/handlers/api-get/milestoneICS.ts +++ b/handlers/api-get/milestoneICS.ts @@ -146,7 +146,7 @@ function buildEventDescriptionHTML_lots( ): string { let descriptionHTML = '' - if (milestone.workOrderLots.length > 0) { + if (milestone.workOrderLots!.length > 0) { const urlRoot = getUrlRoot(request) descriptionHTML += @@ -388,10 +388,10 @@ export async function handler(request: Request, response: Response): Promise 0) { + if (milestone.workOrderLotOccupancies!.length > 0) { let organizerSet = false - for (const lotOccupancy of milestone.workOrderLotOccupancies) { - for (const occupant of lotOccupancy.lotOccupancyOccupants) { + for (const lotOccupancy of milestone.workOrderLotOccupancies!) { + for (const occupant of lotOccupancy.lotOccupancyOccupants!) { if (organizerSet) { calendarEvent.createAttendee({ name: occupant.occupantName, diff --git a/helpers/functions.api.js b/helpers/functions.api.js index 4d5f3295..03d93cd0 100644 --- a/helpers/functions.api.js +++ b/helpers/functions.api.js @@ -23,17 +23,17 @@ async function saveApiKeys() { } } function generateApiKey(apiKeyPrefix) { - return apiKeyPrefix + '-' + uuidv4() + '-' + Date.now(); + return `${apiKeyPrefix}-${uuidv4()}-${Date.now()}`; } export async function regenerateApiKey(userName) { apiKeys[userName] = generateApiKey(userName); await saveApiKeys(); } export async function getApiKey(userName) { - if (!apiKeys) { + if (apiKeys === undefined) { await loadApiKeys(); } - if (!apiKeys[userName]) { + if (!Object.hasOwn(apiKeys, userName)) { await regenerateApiKey(userName); } return apiKeys[userName]; @@ -42,7 +42,7 @@ export async function getApiKeyFromSession(session) { return await getApiKey(session.user.userName); } export async function getUserNameFromApiKey(apiKey) { - if (!apiKeys) { + if (apiKeys === undefined) { await loadApiKeys(); } for (const [userName, currentApiKey] of Object.entries(apiKeys)) { diff --git a/helpers/functions.api.ts b/helpers/functions.api.ts index 818713e7..664188e0 100644 --- a/helpers/functions.api.ts +++ b/helpers/functions.api.ts @@ -29,7 +29,7 @@ async function saveApiKeys(): Promise { } function generateApiKey(apiKeyPrefix: string): string { - return apiKeyPrefix + '-' + uuidv4() + '-' + Date.now() + return `${apiKeyPrefix}-${uuidv4()}-${Date.now()}` } export async function regenerateApiKey(userName: string): Promise { @@ -38,11 +38,11 @@ export async function regenerateApiKey(userName: string): Promise { } export async function getApiKey(userName: string): Promise { - if (!apiKeys) { + if (apiKeys === undefined) { await loadApiKeys() } - if (!apiKeys[userName]) { + if (!Object.hasOwn(apiKeys, userName)) { await regenerateApiKey(userName) } @@ -58,7 +58,7 @@ export async function getApiKeyFromSession( export async function getUserNameFromApiKey( apiKey: string ): Promise { - if (!apiKeys) { + if (apiKeys === undefined) { await loadApiKeys() } diff --git a/helpers/functions.authentication.js b/helpers/functions.authentication.js index 7203338a..0c04746d 100644 --- a/helpers/functions.authentication.js +++ b/helpers/functions.authentication.js @@ -20,7 +20,7 @@ async function authenticateViaActiveDirectory(userName, password) { }); } export async function authenticate(userName, password) { - if (!userName || userName === '' || !password || password === '') { + if ((userName ?? '') === '' || (password ?? '') === '') { return false; } return await authenticateViaActiveDirectory(userName, password); diff --git a/helpers/functions.authentication.ts b/helpers/functions.authentication.ts index 83fa21a5..c8ee6eaf 100644 --- a/helpers/functions.authentication.ts +++ b/helpers/functions.authentication.ts @@ -33,7 +33,7 @@ export async function authenticate( userName: string, password: string ): Promise { - if (!userName || userName === '' || !password || password === '') { + if ((userName ?? '') === '' || (password ?? '') === '') { return false } diff --git a/helpers/functions.lotOccupancy.js b/helpers/functions.lotOccupancy.js index 8ae0db53..b6a3df4c 100644 --- a/helpers/functions.lotOccupancy.js +++ b/helpers/functions.lotOccupancy.js @@ -12,10 +12,10 @@ export function getFieldValueByOccupancyTypeField(lotOccupancy, occupancyTypeFie return (possibleField.occupancyTypeField.toLowerCase() === occupancyTypeFieldLowerCase); }); - if (field) { - return field.lotOccupancyFieldValue; + if (field === undefined) { + return undefined; } - return undefined; + return field.lotOccupancyFieldValue; } export function getFeesByFeeCategory(lotOccupancy, feeCategory, feeCategoryContains = false) { const feeCategoryLowerCase = feeCategory.toLowerCase(); diff --git a/helpers/functions.lotOccupancy.ts b/helpers/functions.lotOccupancy.ts index 826c8214..c5b45bfc 100644 --- a/helpers/functions.lotOccupancy.ts +++ b/helpers/functions.lotOccupancy.ts @@ -33,11 +33,11 @@ export function getFieldValueByOccupancyTypeField( } ) - if (field) { - return field.lotOccupancyFieldValue + if (field === undefined) { + return undefined } - return undefined + return field.lotOccupancyFieldValue } export function getFeesByFeeCategory( diff --git a/helpers/functions.map.js b/helpers/functions.map.js index fa8cd0d8..eb9d869b 100644 --- a/helpers/functions.map.js +++ b/helpers/functions.map.js @@ -1,7 +1,7 @@ import fs from 'node:fs/promises'; let mapSVGs; export async function getMapSVGs() { - if (!mapSVGs) { + if (mapSVGs === undefined) { const files = await fs.readdir('./public/images/maps/'); const SVGs = []; for (const file of files) { diff --git a/helpers/functions.map.ts b/helpers/functions.map.ts index ddde8d71..b34b4caf 100644 --- a/helpers/functions.map.ts +++ b/helpers/functions.map.ts @@ -3,7 +3,7 @@ import fs from 'node:fs/promises' let mapSVGs: string[] export async function getMapSVGs(): Promise { - if (!mapSVGs) { + if (mapSVGs === undefined) { const files = await fs.readdir('./public/images/maps/') const SVGs: string[] = [] diff --git a/helpers/functions.sqlFilters.js b/helpers/functions.sqlFilters.js index 9e94f2ff..9effeab7 100644 --- a/helpers/functions.sqlFilters.js +++ b/helpers/functions.sqlFilters.js @@ -32,33 +32,31 @@ export function getLotNameWhereClause(lotName = '', lotNameSearchType, lotsTable export function getOccupancyTimeWhereClause(occupancyTime, lotOccupanciesTableAlias = 'o') { let sqlWhereClause = ''; const sqlParameters = []; - if (occupancyTime) { - const currentDateString = dateToInteger(new Date()); - switch (occupancyTime) { - case 'current': { - sqlWhereClause += - ' and ' + - lotOccupanciesTableAlias + - '.occupancyStartDate <= ? and (' + - lotOccupanciesTableAlias + - '.occupancyEndDate is null or ' + - lotOccupanciesTableAlias + - '.occupancyEndDate >= ?)'; - sqlParameters.push(currentDateString, currentDateString); - break; - } - case 'past': { - sqlWhereClause += - ' and ' + lotOccupanciesTableAlias + '.occupancyEndDate < ?'; - sqlParameters.push(currentDateString); - break; - } - case 'future': { - sqlWhereClause += - ' and ' + lotOccupanciesTableAlias + '.occupancyStartDate > ?'; - sqlParameters.push(currentDateString); - break; - } + const currentDateString = dateToInteger(new Date()); + switch (occupancyTime ?? '') { + case 'current': { + sqlWhereClause += + ' and ' + + lotOccupanciesTableAlias + + '.occupancyStartDate <= ? and (' + + lotOccupanciesTableAlias + + '.occupancyEndDate is null or ' + + lotOccupanciesTableAlias + + '.occupancyEndDate >= ?)'; + sqlParameters.push(currentDateString, currentDateString); + break; + } + case 'past': { + sqlWhereClause += + ' and ' + lotOccupanciesTableAlias + '.occupancyEndDate < ?'; + sqlParameters.push(currentDateString); + break; + } + case 'future': { + sqlWhereClause += + ' and ' + lotOccupanciesTableAlias + '.occupancyStartDate > ?'; + sqlParameters.push(currentDateString); + break; } } return { @@ -72,7 +70,7 @@ export function getOccupantNameWhereClause(occupantName = '', tableAlias = 'o') if (occupantName !== '') { const occupantNamePieces = occupantName.toLowerCase().split(' '); for (const occupantNamePiece of occupantNamePieces) { - sqlWhereClause += ' and instr(lower(' + tableAlias + '.occupantName), ?)'; + sqlWhereClause += ` and instr(lower(${tableAlias}.occupantName), ?)`; sqlParameters.push(occupantNamePiece); } } diff --git a/helpers/functions.sqlFilters.ts b/helpers/functions.sqlFilters.ts index 83b18fd2..042ff36a 100644 --- a/helpers/functions.sqlFilters.ts +++ b/helpers/functions.sqlFilters.ts @@ -53,36 +53,34 @@ export function getOccupancyTimeWhereClause( let sqlWhereClause = '' const sqlParameters: unknown[] = [] - if (occupancyTime) { - const currentDateString = dateToInteger(new Date()) + const currentDateString = dateToInteger(new Date()) - switch (occupancyTime) { - case 'current': { - sqlWhereClause += - ' and ' + - lotOccupanciesTableAlias + - '.occupancyStartDate <= ? and (' + - lotOccupanciesTableAlias + - '.occupancyEndDate is null or ' + - lotOccupanciesTableAlias + - '.occupancyEndDate >= ?)' - sqlParameters.push(currentDateString, currentDateString) - break - } + switch (occupancyTime ?? '') { + case 'current': { + sqlWhereClause += + ' and ' + + lotOccupanciesTableAlias + + '.occupancyStartDate <= ? and (' + + lotOccupanciesTableAlias + + '.occupancyEndDate is null or ' + + lotOccupanciesTableAlias + + '.occupancyEndDate >= ?)' + sqlParameters.push(currentDateString, currentDateString) + break + } - case 'past': { - sqlWhereClause += - ' and ' + lotOccupanciesTableAlias + '.occupancyEndDate < ?' - sqlParameters.push(currentDateString) - break - } + case 'past': { + sqlWhereClause += + ' and ' + lotOccupanciesTableAlias + '.occupancyEndDate < ?' + sqlParameters.push(currentDateString) + break + } - case 'future': { - sqlWhereClause += - ' and ' + lotOccupanciesTableAlias + '.occupancyStartDate > ?' - sqlParameters.push(currentDateString) - break - } + case 'future': { + sqlWhereClause += + ' and ' + lotOccupanciesTableAlias + '.occupancyStartDate > ?' + sqlParameters.push(currentDateString) + break } } @@ -102,7 +100,7 @@ export function getOccupantNameWhereClause( if (occupantName !== '') { const occupantNamePieces = occupantName.toLowerCase().split(' ') for (const occupantNamePiece of occupantNamePieces) { - sqlWhereClause += ' and instr(lower(' + tableAlias + '.occupantName), ?)' + sqlWhereClause += ` and instr(lower(${tableAlias}.occupantName), ?)` sqlParameters.push(occupantNamePiece) } } diff --git a/helpers/initializer.database.js b/helpers/initializer.database.js index ba72e42a..3b933699 100644 --- a/helpers/initializer.database.js +++ b/helpers/initializer.database.js @@ -54,7 +54,7 @@ export function initializeDatabase() { const row = lotOccupancyDB .prepare("select name from sqlite_master where type = 'table' and name = 'WorkOrderMilestones'") .get(); - if (!row) { + if (row === undefined) { debugSQL('Creating ' + databasePath); for (const sql of createStatements) { lotOccupancyDB.prepare(sql).run(); diff --git a/helpers/initializer.database.ts b/helpers/initializer.database.ts index d907253e..d3605c56 100644 --- a/helpers/initializer.database.ts +++ b/helpers/initializer.database.ts @@ -74,7 +74,7 @@ export function initializeDatabase(): boolean { ) .get() - if (!row) { + if (row === undefined) { debugSQL('Creating ' + databasePath) for (const sql of createStatements) { diff --git a/helpers/lotOccupancyDB/pool.js b/helpers/lotOccupancyDB/pool.js index dabcab0b..e0e8f74c 100644 --- a/helpers/lotOccupancyDB/pool.js +++ b/helpers/lotOccupancyDB/pool.js @@ -1,10 +1,13 @@ import { Pool } from 'better-sqlite-pool'; import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js'; import exitHook from 'exit-hook'; +import Debug from 'debug'; +const debug = Debug('lot-occupancy-system:lotOccupancyDB:pool'); const pool = new Pool(databasePath); export async function acquireConnection() { return await pool.acquire(); } exitHook(() => { + debug('Closing database pool'); pool.close(); }); diff --git a/helpers/lotOccupancyDB/pool.ts b/helpers/lotOccupancyDB/pool.ts index 785d0c5b..ceefaab3 100644 --- a/helpers/lotOccupancyDB/pool.ts +++ b/helpers/lotOccupancyDB/pool.ts @@ -4,6 +4,9 @@ import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js' import exitHook from 'exit-hook' +import Debug from 'debug' +const debug = Debug('lot-occupancy-system:lotOccupancyDB:pool') + const pool = new Pool(databasePath) export async function acquireConnection(): Promise { @@ -11,5 +14,6 @@ export async function acquireConnection(): Promise { } exitHook(() => { + debug('Closing database pool') pool.close() }) diff --git a/routes/admin.ts b/routes/admin.ts index d04c0776..222f0f57 100644 --- a/routes/admin.ts +++ b/routes/admin.ts @@ -1,4 +1,4 @@ -import { Router } from 'express' +import { Router, RequestHandler } from 'express' // Fee Management @@ -96,174 +96,261 @@ export const router = Router() * Fees */ -router.get('/fees', handler_fees) +router.get('/fees', handler_fees as RequestHandler) -router.post('/doAddFeeCategory', handler_doAddFeeCategory) +router.post('/doAddFeeCategory', handler_doAddFeeCategory as RequestHandler) -router.post('/doUpdateFeeCategory', handler_doUpdateFeeCategory) +router.post( + '/doUpdateFeeCategory', + handler_doUpdateFeeCategory as RequestHandler +) -router.post('/doMoveFeeCategoryUp', handler_doMoveFeeCategoryUp) +router.post( + '/doMoveFeeCategoryUp', + handler_doMoveFeeCategoryUp as RequestHandler +) -router.post('/doMoveFeeCategoryDown', handler_doMoveFeeCategoryDown) +router.post( + '/doMoveFeeCategoryDown', + handler_doMoveFeeCategoryDown as RequestHandler +) -router.post('/doDeleteFeeCategory', handler_doDeleteFeeCategory) +router.post( + '/doDeleteFeeCategory', + handler_doDeleteFeeCategory as RequestHandler +) -router.post('/doAddFee', handler_doAddFee) +router.post('/doAddFee', handler_doAddFee as RequestHandler) -router.post('/doUpdateFee', handler_doUpdateFee) +router.post('/doUpdateFee', handler_doUpdateFee as RequestHandler) -router.post('/doMoveFeeUp', handler_doMoveFeeUp) +router.post('/doMoveFeeUp', handler_doMoveFeeUp as RequestHandler) -router.post('/doMoveFeeDown', handler_doMoveFeeDown) +router.post('/doMoveFeeDown', handler_doMoveFeeDown as RequestHandler) -router.post('/doDeleteFee', handler_doDeleteFee) +router.post('/doDeleteFee', handler_doDeleteFee as RequestHandler) /* * Occupancy Type Management */ -router.get('/occupancyTypes', handler_occupancyTypes) +router.get('/occupancyTypes', handler_occupancyTypes as RequestHandler) -router.post('/doAddOccupancyType', handler_doAddOccupancyType) +router.post('/doAddOccupancyType', handler_doAddOccupancyType as RequestHandler) -router.post('/doUpdateOccupancyType', handler_doUpdateOccupancyType) +router.post( + '/doUpdateOccupancyType', + handler_doUpdateOccupancyType as RequestHandler +) -router.post('/doMoveOccupancyTypeUp', handler_doMoveOccupancyTypeUp) +router.post( + '/doMoveOccupancyTypeUp', + handler_doMoveOccupancyTypeUp as RequestHandler +) -router.post('/doMoveOccupancyTypeDown', handler_doMoveOccupancyTypeDown) +router.post( + '/doMoveOccupancyTypeDown', + handler_doMoveOccupancyTypeDown as RequestHandler +) -router.post('/doDeleteOccupancyType', handler_doDeleteOccupancyType) +router.post( + '/doDeleteOccupancyType', + handler_doDeleteOccupancyType as RequestHandler +) // Occupancy Type Fields -router.post('/doAddOccupancyTypeField', handler_doAddOccupancyTypeField) +router.post( + '/doAddOccupancyTypeField', + handler_doAddOccupancyTypeField as RequestHandler +) -router.post('/doUpdateOccupancyTypeField', handler_doUpdateOccupancyTypeField) +router.post( + '/doUpdateOccupancyTypeField', + handler_doUpdateOccupancyTypeField as RequestHandler +) -router.post('/doMoveOccupancyTypeFieldUp', handler_doMoveOccupancyTypeFieldUp) +router.post( + '/doMoveOccupancyTypeFieldUp', + handler_doMoveOccupancyTypeFieldUp as RequestHandler +) router.post( '/doMoveOccupancyTypeFieldDown', - handler_doMoveOccupancyTypeFieldDown + handler_doMoveOccupancyTypeFieldDown as RequestHandler ) -router.post('/doDeleteOccupancyTypeField', handler_doDeleteOccupancyTypeField) +router.post( + '/doDeleteOccupancyTypeField', + handler_doDeleteOccupancyTypeField as RequestHandler +) // Occupancy Type Prints -router.post('/doAddOccupancyTypePrint', handler_doAddOccupancyTypePrint) +router.post( + '/doAddOccupancyTypePrint', + handler_doAddOccupancyTypePrint as RequestHandler +) -router.post('/doMoveOccupancyTypePrintUp', handler_doMoveOccupancyTypePrintUp) +router.post( + '/doMoveOccupancyTypePrintUp', + handler_doMoveOccupancyTypePrintUp as RequestHandler +) router.post( '/doMoveOccupancyTypePrintDown', - handler_doMoveOccupancyTypePrintDown + handler_doMoveOccupancyTypePrintDown as RequestHandler ) -router.post('/doDeleteOccupancyTypePrint', handler_doDeleteOccupancyTypePrint) +router.post( + '/doDeleteOccupancyTypePrint', + handler_doDeleteOccupancyTypePrint as RequestHandler +) /* * Lot Type Management */ -router.get('/lotTypes', handler_lotTypes) +router.get('/lotTypes', handler_lotTypes as RequestHandler) -router.post('/doAddLotType', handler_doAddLotType) +router.post('/doAddLotType', handler_doAddLotType as RequestHandler) -router.post('/doUpdateLotType', handler_doUpdateLotType) +router.post('/doUpdateLotType', handler_doUpdateLotType as RequestHandler) -router.post('/doMoveLotTypeUp', handler_doMoveLotTypeUp) +router.post('/doMoveLotTypeUp', handler_doMoveLotTypeUp as RequestHandler) -router.post('/doMoveLotTypeDown', handler_doMoveLotTypeDown) +router.post('/doMoveLotTypeDown', handler_doMoveLotTypeDown as RequestHandler) -router.post('/doDeleteLotType', handler_doDeleteLotType) +router.post('/doDeleteLotType', handler_doDeleteLotType as RequestHandler) // Lot Type Fields -router.post('/doAddLotTypeField', handler_doAddLotTypeField) +router.post('/doAddLotTypeField', handler_doAddLotTypeField as RequestHandler) -router.post('/doUpdateLotTypeField', handler_doUpdateLotTypeField) +router.post( + '/doUpdateLotTypeField', + handler_doUpdateLotTypeField as RequestHandler +) -router.post('/doMoveLotTypeFieldUp', handler_doMoveLotTypeFieldUp) +router.post( + '/doMoveLotTypeFieldUp', + handler_doMoveLotTypeFieldUp as RequestHandler +) -router.post('/doMoveLotTypeFieldDown', handler_doMoveLotTypeFieldDown) +router.post( + '/doMoveLotTypeFieldDown', + handler_doMoveLotTypeFieldDown as RequestHandler +) -router.post('/doDeleteLotTypeField', handler_doDeleteLotTypeField) +router.post( + '/doDeleteLotTypeField', + handler_doDeleteLotTypeField as RequestHandler +) /* * Config Tables */ -router.get('/tables', handler_tables) +router.get('/tables', handler_tables as RequestHandler) // Config Tables - Work Order Types -router.post('/doAddWorkOrderType', handler_doAddWorkOrderType) +router.post('/doAddWorkOrderType', handler_doAddWorkOrderType as RequestHandler) -router.post('/doUpdateWorkOrderType', handler_doUpdateWorkOrderType) +router.post( + '/doUpdateWorkOrderType', + handler_doUpdateWorkOrderType as RequestHandler +) -router.post('/doMoveWorkOrderTypeUp', handler_doMoveWorkOrderTypeUp) +router.post( + '/doMoveWorkOrderTypeUp', + handler_doMoveWorkOrderTypeUp as RequestHandler +) -router.post('/doMoveWorkOrderTypeDown', handler_doMoveWorkOrderTypeDown) +router.post( + '/doMoveWorkOrderTypeDown', + handler_doMoveWorkOrderTypeDown as RequestHandler +) -router.post('/doDeleteWorkOrderType', handler_doDeleteWorkOrderType) +router.post( + '/doDeleteWorkOrderType', + handler_doDeleteWorkOrderType as RequestHandler +) // Config Tables - Work Order Milestone Types router.post( '/doAddWorkOrderMilestoneType', - handler_doAddWorkOrderMilestoneType + handler_doAddWorkOrderMilestoneType as RequestHandler ) router.post( '/doUpdateWorkOrderMilestoneType', - handler_doUpdateWorkOrderMilestoneType + handler_doUpdateWorkOrderMilestoneType as RequestHandler ) router.post( '/doMoveWorkOrderMilestoneTypeUp', - handler_doMoveWorkOrderMilestoneTypeUp + handler_doMoveWorkOrderMilestoneTypeUp as RequestHandler ) router.post( '/doMoveWorkOrderMilestoneTypeDown', - handler_doMoveWorkOrderMilestoneTypeDown + handler_doMoveWorkOrderMilestoneTypeDown as RequestHandler ) router.post( '/doDeleteWorkOrderMilestoneType', - handler_doDeleteWorkOrderMilestoneType + handler_doDeleteWorkOrderMilestoneType as RequestHandler ) // Config Tables - Lot Statuses -router.post('/doAddLotStatus', handler_doAddLotStatus) +router.post('/doAddLotStatus', handler_doAddLotStatus as RequestHandler) -router.post('/doUpdateLotStatus', handler_doUpdateLotStatus) +router.post('/doUpdateLotStatus', handler_doUpdateLotStatus as RequestHandler) -router.post('/doMoveLotStatusUp', handler_doMoveLotStatusUp) +router.post('/doMoveLotStatusUp', handler_doMoveLotStatusUp as RequestHandler) -router.post('/doMoveLotStatusDown', handler_doMoveLotStatusDown) +router.post( + '/doMoveLotStatusDown', + handler_doMoveLotStatusDown as RequestHandler +) -router.post('/doDeleteLotStatus', handler_doDeleteLotStatus) +router.post('/doDeleteLotStatus', handler_doDeleteLotStatus as RequestHandler) // Config Tables - Lot Occupant Types -router.post('/doAddLotOccupantType', handler_doAddLotOccupantType) +router.post( + '/doAddLotOccupantType', + handler_doAddLotOccupantType as RequestHandler +) -router.post('/doUpdateLotOccupantType', handler_doUpdateLotOccupantType) +router.post( + '/doUpdateLotOccupantType', + handler_doUpdateLotOccupantType as RequestHandler +) -router.post('/doMoveLotOccupantTypeUp', handler_doMoveLotOccupantTypeUp) +router.post( + '/doMoveLotOccupantTypeUp', + handler_doMoveLotOccupantTypeUp as RequestHandler +) -router.post('/doMoveLotOccupantTypeDown', handler_doMoveLotOccupantTypeDown) +router.post( + '/doMoveLotOccupantTypeDown', + handler_doMoveLotOccupantTypeDown as RequestHandler +) -router.post('/doDeleteLotOccupantType', handler_doDeleteLotOccupantType) +router.post( + '/doDeleteLotOccupantType', + handler_doDeleteLotOccupantType as RequestHandler +) // Cleanup router.get('/cleanup', handler_cleanup) -router.post('/doCleanupDatabase', handler_doCleanupDatabase) +router.post('/doCleanupDatabase', handler_doCleanupDatabase as RequestHandler) // Ntfy Startup diff --git a/routes/api.ts b/routes/api.ts index 18a485e1..ff1f1fb6 100644 --- a/routes/api.ts +++ b/routes/api.ts @@ -1,9 +1,9 @@ -import { Router } from 'express' +import { Router, RequestHandler } from 'express' import handler_milestoneICS from '../handlers/api-get/milestoneICS.js' export const router = Router() -router.get('/milestoneICS', handler_milestoneICS) +router.get('/milestoneICS', handler_milestoneICS as RequestHandler) export default router diff --git a/routes/dashboard.ts b/routes/dashboard.ts index 8a5d809d..3bfecba6 100644 --- a/routes/dashboard.ts +++ b/routes/dashboard.ts @@ -1,9 +1,9 @@ -import { Router } from 'express' +import { Router, RequestHandler } from 'express' import handler_dashboard from '../handlers/dashboard-get/dashboard.js' export const router = Router() -router.get('/', handler_dashboard) +router.get('/', handler_dashboard as RequestHandler) export default router diff --git a/routes/lotOccupancies.ts b/routes/lotOccupancies.ts index 6a977ba6..77d214aa 100644 --- a/routes/lotOccupancies.ts +++ b/routes/lotOccupancies.ts @@ -1,4 +1,4 @@ -import { Router } from 'express' +import { RequestHandler, Router } from 'express' import handler_search from '../handlers/lotOccupancies-get/search.js' import handler_doSearchLotOccupancies from '../handlers/lotOccupancies-post/doSearchLotOccupancies.js' @@ -36,54 +36,61 @@ export const router = Router() // Search -router.get('/', handler_search) +router.get('/', handler_search as RequestHandler) -router.post('/doSearchLotOccupancies', handler_doSearchLotOccupancies) +router.post( + '/doSearchLotOccupancies', + handler_doSearchLotOccupancies as RequestHandler +) // Create -router.get('/new', permissionHandlers.updateGetHandler, handler_new) +router.get( + '/new', + permissionHandlers.updateGetHandler, + handler_new as RequestHandler +) router.post( '/doGetOccupancyTypeFields', permissionHandlers.updatePostHandler, - handler_doGetOccupancyTypeFields + handler_doGetOccupancyTypeFields as RequestHandler ) router.post( '/doCreateLotOccupancy', permissionHandlers.updatePostHandler, - handler_doCreateLotOccupancy + handler_doCreateLotOccupancy as RequestHandler ) // View -router.get('/:lotOccupancyId', handler_view) +router.get('/:lotOccupancyId', handler_view as RequestHandler) // Edit router.get( '/:lotOccupancyId/edit', permissionHandlers.updateGetHandler, - handler_edit + handler_edit as RequestHandler ) router.post( '/doUpdateLotOccupancy', permissionHandlers.updatePostHandler, - handler_doUpdateLotOccupancy + handler_doUpdateLotOccupancy as RequestHandler ) router.post( '/doCopyLotOccupancy', permissionHandlers.updatePostHandler, - handler_doCopyLotOccupancy + handler_doCopyLotOccupancy as RequestHandler ) router.post( '/doDeleteLotOccupancy', permissionHandlers.updatePostHandler, - handler_doDeleteLotOccupancy + handler_doDeleteLotOccupancy as RequestHandler ) // Occupants @@ -91,25 +98,25 @@ router.post( router.post( '/doSearchPastOccupants', permissionHandlers.updatePostHandler, - handler_doSearchPastOccupants + handler_doSearchPastOccupants as RequestHandler ) router.post( '/doAddLotOccupancyOccupant', permissionHandlers.updatePostHandler, - handler_doAddLotOccupancyOccupant + handler_doAddLotOccupancyOccupant as RequestHandler ) router.post( '/doUpdateLotOccupancyOccupant', permissionHandlers.updatePostHandler, - handler_doUpdateLotOccupancyOccupant + handler_doUpdateLotOccupancyOccupant as RequestHandler ) router.post( '/doDeleteLotOccupancyOccupant', permissionHandlers.updatePostHandler, - handler_doDeleteLotOccupancyOccupant + handler_doDeleteLotOccupancyOccupant as RequestHandler ) // Comments @@ -117,19 +124,19 @@ router.post( router.post( '/doAddLotOccupancyComment', permissionHandlers.updatePostHandler, - handler_doAddLotOccupancyComment + handler_doAddLotOccupancyComment as RequestHandler ) router.post( '/doUpdateLotOccupancyComment', permissionHandlers.updatePostHandler, - handler_doUpdateLotOccupancyComment + handler_doUpdateLotOccupancyComment as RequestHandler ) router.post( '/doDeleteLotOccupancyComment', permissionHandlers.updatePostHandler, - handler_doDeleteLotOccupancyComment + handler_doDeleteLotOccupancyComment as RequestHandler ) // Fees @@ -137,19 +144,19 @@ router.post( router.post( '/doGetFees', permissionHandlers.updatePostHandler, - handler_doGetFees + handler_doGetFees as RequestHandler ) router.post( '/doAddLotOccupancyFee', permissionHandlers.updatePostHandler, - handler_doAddLotOccupancyFee + handler_doAddLotOccupancyFee as RequestHandler ) router.post( '/doDeleteLotOccupancyFee', permissionHandlers.updatePostHandler, - handler_doDeleteLotOccupancyFee + handler_doDeleteLotOccupancyFee as RequestHandler ) // Transactions @@ -157,13 +164,13 @@ router.post( router.post( '/doAddLotOccupancyTransaction', permissionHandlers.updatePostHandler, - handler_doAddLotOccupancyTransaction + handler_doAddLotOccupancyTransaction as RequestHandler ) router.post( '/doDeleteLotOccupancyTransaction', permissionHandlers.updatePostHandler, - handler_doDeleteLotOccupancyTransaction + handler_doDeleteLotOccupancyTransaction as RequestHandler ) export default router diff --git a/routes/lots.ts b/routes/lots.ts index dbf1e08a..d3321a0c 100644 --- a/routes/lots.ts +++ b/routes/lots.ts @@ -1,4 +1,4 @@ -import { Router } from 'express' +import { RequestHandler, Router } from 'express' import * as permissionHandlers from '../handlers/permissions.js' @@ -28,64 +28,72 @@ export const router = Router() * Lot Search */ -router.get('/', handler_search) +router.get('/', handler_search as RequestHandler) -router.post('/doSearchLots', handler_doSearchLots) +router.post('/doSearchLots', handler_doSearchLots as RequestHandler) /* * Lot View / Edit */ -router.get('/new', permissionHandlers.updateGetHandler, handler_new) +router.get( + '/new', + permissionHandlers.updateGetHandler, + handler_new as RequestHandler +) -router.get('/:lotId', handler_view) +router.get('/:lotId', handler_view as RequestHandler) -router.get('/:lotId/next', handler_next) +router.get('/:lotId/next', handler_next as RequestHandler) -router.get('/:lotId/previous', handler_previous) +router.get('/:lotId/previous', handler_previous as RequestHandler) -router.get('/:lotId/edit', permissionHandlers.updateGetHandler, handler_edit) +router.get( + '/:lotId/edit', + permissionHandlers.updateGetHandler, + handler_edit as RequestHandler +) router.post( '/doGetLotTypeFields', permissionHandlers.updatePostHandler, - handler_doGetLotTypeFields + handler_doGetLotTypeFields as RequestHandler ) router.post( '/doCreateLot', permissionHandlers.updatePostHandler, - handler_doCreateLot + handler_doCreateLot as RequestHandler ) router.post( '/doUpdateLot', permissionHandlers.updatePostHandler, - handler_doUpdateLot + handler_doUpdateLot as RequestHandler ) router.post( '/doDeleteLot', permissionHandlers.updatePostHandler, - handler_doDeleteLot + handler_doDeleteLot as RequestHandler ) router.post( '/doAddLotComment', permissionHandlers.updatePostHandler, - handler_doAddLotComment + handler_doAddLotComment as RequestHandler ) router.post( '/doUpdateLotComment', permissionHandlers.updatePostHandler, - handler_doUpdateLotComment + handler_doUpdateLotComment as RequestHandler ) router.post( '/doDeleteLotComment', permissionHandlers.updatePostHandler, - handler_doDeleteLotComment + handler_doDeleteLotComment as RequestHandler ) export default router diff --git a/routes/maps.ts b/routes/maps.ts index b72ee681..07416e5e 100644 --- a/routes/maps.ts +++ b/routes/maps.ts @@ -1,4 +1,4 @@ -import { Router } from 'express' +import { RequestHandler, Router } from 'express' import * as permissionHandlers from '../handlers/permissions.js' @@ -14,30 +14,38 @@ import handler_doDeleteMap from '../handlers/maps-post/doDeleteMap.js' export const router = Router() -router.get('/', handler_search) +router.get('/', handler_search as RequestHandler) -router.get('/new', permissionHandlers.updateGetHandler, handler_new) +router.get( + '/new', + permissionHandlers.updateGetHandler, + handler_new as RequestHandler +) -router.get('/:mapId', handler_view) +router.get('/:mapId', handler_view as RequestHandler) -router.get('/:mapId/edit', permissionHandlers.updateGetHandler, handler_edit) +router.get( + '/:mapId/edit', + permissionHandlers.updateGetHandler, + handler_edit as RequestHandler +) router.post( '/doCreateMap', permissionHandlers.updatePostHandler, - handler_doCreateMap + handler_doCreateMap as RequestHandler ) router.post( '/doUpdateMap', permissionHandlers.updatePostHandler, - handler_doUpdateMap + handler_doUpdateMap as RequestHandler ) router.post( '/doDeleteMap', permissionHandlers.updatePostHandler, - handler_doDeleteMap + handler_doDeleteMap as RequestHandler ) export default router diff --git a/routes/print.ts b/routes/print.ts index 4bde9296..0f42f83b 100644 --- a/routes/print.ts +++ b/routes/print.ts @@ -1,12 +1,12 @@ -import { Router } from 'express' +import { RequestHandler, Router } from 'express' import handler_screen from '../handlers/print-get/screen.js' import handler_pdf from '../handlers/print-get/pdf.js' export const router = Router() -router.get('/screen/:printName', handler_screen) +router.get('/screen/:printName', handler_screen as RequestHandler) -router.get('/pdf/:printName', handler_pdf) +router.get('/pdf/:printName', handler_pdf as RequestHandler) export default router diff --git a/routes/reports.ts b/routes/reports.ts index 5f499bb7..65026a34 100644 --- a/routes/reports.ts +++ b/routes/reports.ts @@ -1,12 +1,12 @@ -import { Router } from 'express' +import { RequestHandler, Router } from 'express' import handler_search from '../handlers/reports-get/search.js' import handler_reportName from '../handlers/reports-get/reportName.js' export const router = Router() -router.get('/', handler_search) +router.get('/', handler_search as RequestHandler) -router.all('/:reportName', handler_reportName) +router.all('/:reportName', handler_reportName as RequestHandler) export default router diff --git a/routes/workOrders.ts b/routes/workOrders.ts index 9e0f8c07..8a7510f3 100644 --- a/routes/workOrders.ts +++ b/routes/workOrders.ts @@ -1,4 +1,4 @@ -import { Router } from 'express' +import { RequestHandler, Router } from 'express' import * as permissionHandlers from '../handlers/permissions.js' @@ -42,38 +42,45 @@ export const router = Router() // Search -router.get('/', handler_search) +router.get('/', handler_search as RequestHandler) -router.post('/doSearchWorkOrders', handler_doSearchWorkOrders) +router.post('/doSearchWorkOrders', handler_doSearchWorkOrders as RequestHandler) // Milestone Calendar -router.get('/milestoneCalendar', handler_milestoneCalendar) +router.get('/milestoneCalendar', handler_milestoneCalendar as RequestHandler) -router.post('/doGetWorkOrderMilestones', handler_doGetWorkOrderMilestones) +router.post( + '/doGetWorkOrderMilestones', + handler_doGetWorkOrderMilestones as RequestHandler +) // Outlook Integration -router.get('/outlook', handler_outlook) +router.get('/outlook', handler_outlook as RequestHandler) // New -router.get('/new', permissionHandlers.adminGetHandler, handler_new) +router.get( + '/new', + permissionHandlers.adminGetHandler, + handler_new as RequestHandler +) router.post( '/doCreateWorkOrder', permissionHandlers.updatePostHandler, - handler_doCreateWorkOrder + handler_doCreateWorkOrder as RequestHandler ) // View -router.get('/:workOrderId', handler_view) +router.get('/:workOrderId', handler_view as RequestHandler) router.post( '/doReopenWorkOrder', permissionHandlers.updatePostHandler, - handler_doReopenWorkOrder + handler_doReopenWorkOrder as RequestHandler ) // Edit @@ -81,25 +88,25 @@ router.post( router.get( '/:workOrderId/edit', permissionHandlers.updateGetHandler, - handler_edit + handler_edit as RequestHandler ) router.post( '/doUpdateWorkOrder', permissionHandlers.updatePostHandler, - handler_doUpdateWorkOrder + handler_doUpdateWorkOrder as RequestHandler ) router.post( '/doCloseWorkOrder', permissionHandlers.updatePostHandler, - handler_doCloseWorkOrder + handler_doCloseWorkOrder as RequestHandler ) router.post( '/doDeleteWorkOrder', permissionHandlers.updatePostHandler, - handler_doDeleteWorkOrder + handler_doDeleteWorkOrder as RequestHandler ) // Lot Occupancy @@ -107,31 +114,31 @@ router.post( router.post( '/doAddWorkOrderLotOccupancy', permissionHandlers.updatePostHandler, - handler_doAddWorkOrderLotOccupancy + handler_doAddWorkOrderLotOccupancy as RequestHandler ) router.post( '/doDeleteWorkOrderLotOccupancy', permissionHandlers.updatePostHandler, - handler_doDeleteWorkOrderLotOccupancy + handler_doDeleteWorkOrderLotOccupancy as RequestHandler ) router.post( '/doAddWorkOrderLot', permissionHandlers.updatePostHandler, - handler_doAddWorkOrderLot + handler_doAddWorkOrderLot as RequestHandler ) router.post( '/doUpdateLotStatus', permissionHandlers.updatePostHandler, - handler_doUpdateLotStatus + handler_doUpdateLotStatus as RequestHandler ) router.post( '/doDeleteWorkOrderLot', permissionHandlers.updatePostHandler, - handler_doDeleteWorkOrderLot + handler_doDeleteWorkOrderLot as RequestHandler ) // Comments @@ -139,19 +146,19 @@ router.post( router.post( '/doAddWorkOrderComment', permissionHandlers.updatePostHandler, - handler_doAddWorkOrderComment + handler_doAddWorkOrderComment as RequestHandler ) router.post( '/doUpdateWorkOrderComment', permissionHandlers.updatePostHandler, - handler_doUpdateWorkOrderComment + handler_doUpdateWorkOrderComment as RequestHandler ) router.post( '/doDeleteWorkOrderComment', permissionHandlers.updatePostHandler, - handler_doDeleteWorkOrderComment + handler_doDeleteWorkOrderComment as RequestHandler ) // Milestones @@ -159,31 +166,31 @@ router.post( router.post( '/doAddWorkOrderMilestone', permissionHandlers.updatePostHandler, - handler_doAddWorkOrderMilestone + handler_doAddWorkOrderMilestone as RequestHandler ) router.post( '/doUpdateWorkOrderMilestone', permissionHandlers.updatePostHandler, - handler_doUpdateWorkOrderMilestone + handler_doUpdateWorkOrderMilestone as RequestHandler ) router.post( '/doCompleteWorkOrderMilestone', permissionHandlers.updatePostHandler, - handler_doCompleteWorkOrderMilestone + handler_doCompleteWorkOrderMilestone as RequestHandler ) router.post( '/doReopenWorkOrderMilestone', permissionHandlers.updatePostHandler, - handler_doReopenWorkOrderMilestone + handler_doReopenWorkOrderMilestone as RequestHandler ) router.post( '/doDeleteWorkOrderMilestone', permissionHandlers.updatePostHandler, - handler_doDeleteWorkOrderMilestone + handler_doDeleteWorkOrderMilestone as RequestHandler ) export default router