From ef4be9000370d103eab08ffe74846bb2c5b43ede Mon Sep 17 00:00:00 2001 From: Dan Gowans Date: Thu, 27 Jun 2024 15:16:46 -0400 Subject: [PATCH] wildcard imports --- routes/lots.js | 20 +++++++++--------- routes/lots.ts | 28 +++++++++---------------- routes/maps.js | 12 +++++------ routes/maps.ts | 20 ++++++------------ routes/workOrders.js | 42 ++++++++++++++++++------------------- routes/workOrders.ts | 46 +++++++++++++++++++---------------------- test/1_serverCypress.js | 2 +- test/1_serverCypress.ts | 2 +- 8 files changed, 76 insertions(+), 96 deletions(-) diff --git a/routes/lots.js b/routes/lots.js index 3a30834d..dcc9bcda 100644 --- a/routes/lots.js +++ b/routes/lots.js @@ -13,7 +13,7 @@ import handler_doGetLotTypeFields from '../handlers/lots-post/doGetLotTypeFields import handler_doSearchLots from '../handlers/lots-post/doSearchLots.js'; import handler_doUpdateLot from '../handlers/lots-post/doUpdateLot.js'; import handler_doUpdateLotComment from '../handlers/lots-post/doUpdateLotComment.js'; -import * as permissionHandlers from '../handlers/permissions.js'; +import { updateGetHandler, updatePostHandler } from '../handlers/permissions.js'; export const router = Router(); /* * Lot Search @@ -23,16 +23,16 @@ router.post('/doSearchLots', handler_doSearchLots); /* * Lot View / Edit */ -router.get('/new', permissionHandlers.updateGetHandler, handler_new); +router.get('/new', updateGetHandler, handler_new); router.get('/:lotId', handler_view); router.get('/:lotId/next', handler_next); router.get('/:lotId/previous', handler_previous); -router.get('/:lotId/edit', permissionHandlers.updateGetHandler, handler_edit); -router.post('/doGetLotTypeFields', permissionHandlers.updatePostHandler, handler_doGetLotTypeFields); -router.post('/doCreateLot', permissionHandlers.updatePostHandler, handler_doCreateLot); -router.post('/doUpdateLot', permissionHandlers.updatePostHandler, handler_doUpdateLot); -router.post('/doDeleteLot', permissionHandlers.updatePostHandler, handler_doDeleteLot); -router.post('/doAddLotComment', permissionHandlers.updatePostHandler, handler_doAddLotComment); -router.post('/doUpdateLotComment', permissionHandlers.updatePostHandler, handler_doUpdateLotComment); -router.post('/doDeleteLotComment', permissionHandlers.updatePostHandler, handler_doDeleteLotComment); +router.get('/:lotId/edit', updateGetHandler, handler_edit); +router.post('/doGetLotTypeFields', updatePostHandler, handler_doGetLotTypeFields); +router.post('/doCreateLot', updatePostHandler, handler_doCreateLot); +router.post('/doUpdateLot', updatePostHandler, handler_doUpdateLot); +router.post('/doDeleteLot', updatePostHandler, handler_doDeleteLot); +router.post('/doAddLotComment', updatePostHandler, handler_doAddLotComment); +router.post('/doUpdateLotComment', updatePostHandler, handler_doUpdateLotComment); +router.post('/doDeleteLotComment', updatePostHandler, handler_doDeleteLotComment); export default router; diff --git a/routes/lots.ts b/routes/lots.ts index 12f77cea..2f4d5cda 100644 --- a/routes/lots.ts +++ b/routes/lots.ts @@ -14,7 +14,7 @@ import handler_doGetLotTypeFields from '../handlers/lots-post/doGetLotTypeFields import handler_doSearchLots from '../handlers/lots-post/doSearchLots.js' import handler_doUpdateLot from '../handlers/lots-post/doUpdateLot.js' import handler_doUpdateLotComment from '../handlers/lots-post/doUpdateLotComment.js' -import * as permissionHandlers from '../handlers/permissions.js' +import { updateGetHandler, updatePostHandler } from '../handlers/permissions.js' export const router = Router() @@ -30,11 +30,7 @@ router.post('/doSearchLots', handler_doSearchLots as RequestHandler) * Lot View / Edit */ -router.get( - '/new', - permissionHandlers.updateGetHandler, - handler_new as RequestHandler -) +router.get('/new', updateGetHandler, handler_new as RequestHandler) router.get('/:lotId', handler_view as RequestHandler) @@ -42,51 +38,47 @@ router.get('/:lotId/next', handler_next as RequestHandler) router.get('/:lotId/previous', handler_previous as RequestHandler) -router.get( - '/:lotId/edit', - permissionHandlers.updateGetHandler, - handler_edit as RequestHandler -) +router.get('/:lotId/edit', updateGetHandler, handler_edit as RequestHandler) router.post( '/doGetLotTypeFields', - permissionHandlers.updatePostHandler, + updatePostHandler, handler_doGetLotTypeFields as RequestHandler ) router.post( '/doCreateLot', - permissionHandlers.updatePostHandler, + updatePostHandler, handler_doCreateLot as RequestHandler ) router.post( '/doUpdateLot', - permissionHandlers.updatePostHandler, + updatePostHandler, handler_doUpdateLot as RequestHandler ) router.post( '/doDeleteLot', - permissionHandlers.updatePostHandler, + updatePostHandler, handler_doDeleteLot as RequestHandler ) router.post( '/doAddLotComment', - permissionHandlers.updatePostHandler, + updatePostHandler, handler_doAddLotComment as RequestHandler ) router.post( '/doUpdateLotComment', - permissionHandlers.updatePostHandler, + updatePostHandler, handler_doUpdateLotComment as RequestHandler ) router.post( '/doDeleteLotComment', - permissionHandlers.updatePostHandler, + updatePostHandler, handler_doDeleteLotComment as RequestHandler ) diff --git a/routes/maps.js b/routes/maps.js index e6baa182..ed1711db 100644 --- a/routes/maps.js +++ b/routes/maps.js @@ -8,15 +8,15 @@ import handler_view from '../handlers/maps-get/view.js'; import handler_doCreateMap from '../handlers/maps-post/doCreateMap.js'; import handler_doDeleteMap from '../handlers/maps-post/doDeleteMap.js'; import handler_doUpdateMap from '../handlers/maps-post/doUpdateMap.js'; -import * as permissionHandlers from '../handlers/permissions.js'; +import { updateGetHandler, updatePostHandler } from '../handlers/permissions.js'; export const router = Router(); router.get('/', handler_search); -router.get('/new', permissionHandlers.updateGetHandler, handler_new); +router.get('/new', updateGetHandler, handler_new); router.get('/:mapId', handler_view); router.get('/:mapId/next', handler_next); router.get('/:mapId/previous', handler_previous); -router.get('/:mapId/edit', permissionHandlers.updateGetHandler, handler_edit); -router.post('/doCreateMap', permissionHandlers.updatePostHandler, handler_doCreateMap); -router.post('/doUpdateMap', permissionHandlers.updatePostHandler, handler_doUpdateMap); -router.post('/doDeleteMap', permissionHandlers.updatePostHandler, handler_doDeleteMap); +router.get('/:mapId/edit', updateGetHandler, handler_edit); +router.post('/doCreateMap', updatePostHandler, handler_doCreateMap); +router.post('/doUpdateMap', updatePostHandler, handler_doUpdateMap); +router.post('/doDeleteMap', updatePostHandler, handler_doDeleteMap); export default router; diff --git a/routes/maps.ts b/routes/maps.ts index b5318388..7ea0bd93 100644 --- a/routes/maps.ts +++ b/routes/maps.ts @@ -9,17 +9,13 @@ import handler_view from '../handlers/maps-get/view.js' import handler_doCreateMap from '../handlers/maps-post/doCreateMap.js' import handler_doDeleteMap from '../handlers/maps-post/doDeleteMap.js' import handler_doUpdateMap from '../handlers/maps-post/doUpdateMap.js' -import * as permissionHandlers from '../handlers/permissions.js' +import { updateGetHandler, updatePostHandler } from '../handlers/permissions.js' export const router = Router() router.get('/', handler_search as RequestHandler) -router.get( - '/new', - permissionHandlers.updateGetHandler, - handler_new as RequestHandler -) +router.get('/new', updateGetHandler, handler_new as RequestHandler) router.get('/:mapId', handler_view as RequestHandler) @@ -27,27 +23,23 @@ router.get('/:mapId/next', handler_next as RequestHandler) router.get('/:mapId/previous', handler_previous as RequestHandler) -router.get( - '/:mapId/edit', - permissionHandlers.updateGetHandler, - handler_edit as RequestHandler -) +router.get('/:mapId/edit', updateGetHandler, handler_edit as RequestHandler) router.post( '/doCreateMap', - permissionHandlers.updatePostHandler, + updatePostHandler, handler_doCreateMap as RequestHandler ) router.post( '/doUpdateMap', - permissionHandlers.updatePostHandler, + updatePostHandler, handler_doUpdateMap as RequestHandler ) router.post( '/doDeleteMap', - permissionHandlers.updatePostHandler, + updatePostHandler, handler_doDeleteMap as RequestHandler ) diff --git a/routes/workOrders.js b/routes/workOrders.js index 05085513..ad125157 100644 --- a/routes/workOrders.js +++ b/routes/workOrders.js @@ -1,5 +1,5 @@ import { Router } from 'express'; -import * as permissionHandlers from '../handlers/permissions.js'; +import { updateGetHandler, updatePostHandler } from '../handlers/permissions.js'; import handler_edit from '../handlers/workOrders-get/edit.js'; import handler_milestoneCalendar from '../handlers/workOrders-get/milestoneCalendar.js'; import handler_new from '../handlers/workOrders-get/new.js'; @@ -36,30 +36,30 @@ router.post('/doGetWorkOrderMilestones', handler_doGetWorkOrderMilestones); // Outlook Integration router.get('/outlook', handler_outlook); // New -router.get('/new', permissionHandlers.updateGetHandler, handler_new); -router.post('/doCreateWorkOrder', permissionHandlers.updatePostHandler, handler_doCreateWorkOrder); +router.get('/new', updateGetHandler, handler_new); +router.post('/doCreateWorkOrder', updatePostHandler, handler_doCreateWorkOrder); // View router.get('/:workOrderId', handler_view); -router.post('/doReopenWorkOrder', permissionHandlers.updatePostHandler, handler_doReopenWorkOrder); +router.post('/doReopenWorkOrder', updatePostHandler, handler_doReopenWorkOrder); // Edit -router.get('/:workOrderId/edit', permissionHandlers.updateGetHandler, handler_edit); -router.post('/doUpdateWorkOrder', permissionHandlers.updatePostHandler, handler_doUpdateWorkOrder); -router.post('/doCloseWorkOrder', permissionHandlers.updatePostHandler, handler_doCloseWorkOrder); -router.post('/doDeleteWorkOrder', permissionHandlers.updatePostHandler, handler_doDeleteWorkOrder); +router.get('/:workOrderId/edit', updateGetHandler, handler_edit); +router.post('/doUpdateWorkOrder', updatePostHandler, handler_doUpdateWorkOrder); +router.post('/doCloseWorkOrder', updatePostHandler, handler_doCloseWorkOrder); +router.post('/doDeleteWorkOrder', updatePostHandler, handler_doDeleteWorkOrder); // Lot Occupancy -router.post('/doAddWorkOrderLotOccupancy', permissionHandlers.updatePostHandler, handler_doAddWorkOrderLotOccupancy); -router.post('/doDeleteWorkOrderLotOccupancy', permissionHandlers.updatePostHandler, handler_doDeleteWorkOrderLotOccupancy); -router.post('/doAddWorkOrderLot', permissionHandlers.updatePostHandler, handler_doAddWorkOrderLot); -router.post('/doUpdateLotStatus', permissionHandlers.updatePostHandler, handler_doUpdateLotStatus); -router.post('/doDeleteWorkOrderLot', permissionHandlers.updatePostHandler, handler_doDeleteWorkOrderLot); +router.post('/doAddWorkOrderLotOccupancy', updatePostHandler, handler_doAddWorkOrderLotOccupancy); +router.post('/doDeleteWorkOrderLotOccupancy', updatePostHandler, handler_doDeleteWorkOrderLotOccupancy); +router.post('/doAddWorkOrderLot', updatePostHandler, handler_doAddWorkOrderLot); +router.post('/doUpdateLotStatus', updatePostHandler, handler_doUpdateLotStatus); +router.post('/doDeleteWorkOrderLot', updatePostHandler, handler_doDeleteWorkOrderLot); // Comments -router.post('/doAddWorkOrderComment', permissionHandlers.updatePostHandler, handler_doAddWorkOrderComment); -router.post('/doUpdateWorkOrderComment', permissionHandlers.updatePostHandler, handler_doUpdateWorkOrderComment); -router.post('/doDeleteWorkOrderComment', permissionHandlers.updatePostHandler, handler_doDeleteWorkOrderComment); +router.post('/doAddWorkOrderComment', updatePostHandler, handler_doAddWorkOrderComment); +router.post('/doUpdateWorkOrderComment', updatePostHandler, handler_doUpdateWorkOrderComment); +router.post('/doDeleteWorkOrderComment', updatePostHandler, handler_doDeleteWorkOrderComment); // Milestones -router.post('/doAddWorkOrderMilestone', permissionHandlers.updatePostHandler, handler_doAddWorkOrderMilestone); -router.post('/doUpdateWorkOrderMilestone', permissionHandlers.updatePostHandler, handler_doUpdateWorkOrderMilestone); -router.post('/doCompleteWorkOrderMilestone', permissionHandlers.updatePostHandler, handler_doCompleteWorkOrderMilestone); -router.post('/doReopenWorkOrderMilestone', permissionHandlers.updatePostHandler, handler_doReopenWorkOrderMilestone); -router.post('/doDeleteWorkOrderMilestone', permissionHandlers.updatePostHandler, handler_doDeleteWorkOrderMilestone); +router.post('/doAddWorkOrderMilestone', updatePostHandler, handler_doAddWorkOrderMilestone); +router.post('/doUpdateWorkOrderMilestone', updatePostHandler, handler_doUpdateWorkOrderMilestone); +router.post('/doCompleteWorkOrderMilestone', updatePostHandler, handler_doCompleteWorkOrderMilestone); +router.post('/doReopenWorkOrderMilestone', updatePostHandler, handler_doReopenWorkOrderMilestone); +router.post('/doDeleteWorkOrderMilestone', updatePostHandler, handler_doDeleteWorkOrderMilestone); export default router; diff --git a/routes/workOrders.ts b/routes/workOrders.ts index f5cab1c5..3f177091 100644 --- a/routes/workOrders.ts +++ b/routes/workOrders.ts @@ -1,6 +1,6 @@ import { type RequestHandler, Router } from 'express' -import * as permissionHandlers from '../handlers/permissions.js' +import { updateGetHandler, updatePostHandler } from '../handlers/permissions.js' import handler_edit from '../handlers/workOrders-get/edit.js' import handler_milestoneCalendar from '../handlers/workOrders-get/milestoneCalendar.js' import handler_new from '../handlers/workOrders-get/new.js' @@ -51,15 +51,11 @@ router.get('/outlook', handler_outlook as RequestHandler) // New -router.get( - '/new', - permissionHandlers.updateGetHandler, - handler_new as RequestHandler -) +router.get('/new', updateGetHandler, handler_new as RequestHandler) router.post( '/doCreateWorkOrder', - permissionHandlers.updatePostHandler, + updatePostHandler, handler_doCreateWorkOrder as RequestHandler ) @@ -69,7 +65,7 @@ router.get('/:workOrderId', handler_view as RequestHandler) router.post( '/doReopenWorkOrder', - permissionHandlers.updatePostHandler, + updatePostHandler, handler_doReopenWorkOrder as RequestHandler ) @@ -77,25 +73,25 @@ router.post( router.get( '/:workOrderId/edit', - permissionHandlers.updateGetHandler, + updateGetHandler, handler_edit as RequestHandler ) router.post( '/doUpdateWorkOrder', - permissionHandlers.updatePostHandler, + updatePostHandler, handler_doUpdateWorkOrder as RequestHandler ) router.post( '/doCloseWorkOrder', - permissionHandlers.updatePostHandler, + updatePostHandler, handler_doCloseWorkOrder as RequestHandler ) router.post( '/doDeleteWorkOrder', - permissionHandlers.updatePostHandler, + updatePostHandler, handler_doDeleteWorkOrder as RequestHandler ) @@ -103,31 +99,31 @@ router.post( router.post( '/doAddWorkOrderLotOccupancy', - permissionHandlers.updatePostHandler, + updatePostHandler, handler_doAddWorkOrderLotOccupancy as RequestHandler ) router.post( '/doDeleteWorkOrderLotOccupancy', - permissionHandlers.updatePostHandler, + updatePostHandler, handler_doDeleteWorkOrderLotOccupancy as RequestHandler ) router.post( '/doAddWorkOrderLot', - permissionHandlers.updatePostHandler, + updatePostHandler, handler_doAddWorkOrderLot as RequestHandler ) router.post( '/doUpdateLotStatus', - permissionHandlers.updatePostHandler, + updatePostHandler, handler_doUpdateLotStatus as RequestHandler ) router.post( '/doDeleteWorkOrderLot', - permissionHandlers.updatePostHandler, + updatePostHandler, handler_doDeleteWorkOrderLot as RequestHandler ) @@ -135,19 +131,19 @@ router.post( router.post( '/doAddWorkOrderComment', - permissionHandlers.updatePostHandler, + updatePostHandler, handler_doAddWorkOrderComment as RequestHandler ) router.post( '/doUpdateWorkOrderComment', - permissionHandlers.updatePostHandler, + updatePostHandler, handler_doUpdateWorkOrderComment as RequestHandler ) router.post( '/doDeleteWorkOrderComment', - permissionHandlers.updatePostHandler, + updatePostHandler, handler_doDeleteWorkOrderComment as RequestHandler ) @@ -155,31 +151,31 @@ router.post( router.post( '/doAddWorkOrderMilestone', - permissionHandlers.updatePostHandler, + updatePostHandler, handler_doAddWorkOrderMilestone as RequestHandler ) router.post( '/doUpdateWorkOrderMilestone', - permissionHandlers.updatePostHandler, + updatePostHandler, handler_doUpdateWorkOrderMilestone as RequestHandler ) router.post( '/doCompleteWorkOrderMilestone', - permissionHandlers.updatePostHandler, + updatePostHandler, handler_doCompleteWorkOrderMilestone as RequestHandler ) router.post( '/doReopenWorkOrderMilestone', - permissionHandlers.updatePostHandler, + updatePostHandler, handler_doReopenWorkOrderMilestone as RequestHandler ) router.post( '/doDeleteWorkOrderMilestone', - permissionHandlers.updatePostHandler, + updatePostHandler, handler_doDeleteWorkOrderMilestone as RequestHandler ) diff --git a/test/1_serverCypress.js b/test/1_serverCypress.js index d3b69bb3..917d8fa4 100644 --- a/test/1_serverCypress.js +++ b/test/1_serverCypress.js @@ -1,7 +1,7 @@ /* eslint-disable unicorn/filename-case, @eslint-community/eslint-comments/disable-enable-pair */ import assert from 'node:assert'; import { exec } from 'node:child_process'; -import * as http from 'node:http'; +import http from 'node:http'; import { app } from '../app.js'; import { portNumber } from './_globals.js'; function runCypress(browser, done) { diff --git a/test/1_serverCypress.ts b/test/1_serverCypress.ts index c491e5a6..b8cb2dbf 100644 --- a/test/1_serverCypress.ts +++ b/test/1_serverCypress.ts @@ -2,7 +2,7 @@ import assert from 'node:assert' import { exec } from 'node:child_process' -import * as http from 'node:http' +import http from 'node:http' import { app } from '../app.js'