diff --git a/handlers/reports-get/search.d.ts b/handlers/reports-get/search.d.ts new file mode 100644 index 00000000..9621c611 --- /dev/null +++ b/handlers/reports-get/search.d.ts @@ -0,0 +1,3 @@ +import type { RequestHandler } from "express"; +export declare const handler: RequestHandler; +export default handler; diff --git a/handlers/reports-get/search.js b/handlers/reports-get/search.js new file mode 100644 index 00000000..7f976cb3 --- /dev/null +++ b/handlers/reports-get/search.js @@ -0,0 +1,12 @@ +import * as dateTimeFunctions from "@cityssm/expressjs-server-js/dateTimeFns.js"; +import { getMaps } from "../../helpers/lotOccupancyDB/getMaps.js"; +export const handler = (_request, response) => { + const rightNow = new Date(); + const maps = getMaps(); + response.render("report-search", { + headTitle: "Reports", + todayDateString: dateTimeFunctions.dateToString(rightNow), + maps + }); +}; +export default handler; diff --git a/handlers/reports-get/search.ts b/handlers/reports-get/search.ts new file mode 100644 index 00000000..276cc93a --- /dev/null +++ b/handlers/reports-get/search.ts @@ -0,0 +1,19 @@ +import type { RequestHandler } from "express"; + +import * as dateTimeFunctions from "@cityssm/expressjs-server-js/dateTimeFns.js"; + +import { getMaps } from "../../helpers/lotOccupancyDB/getMaps.js"; + +export const handler: RequestHandler = (_request, response) => { + const rightNow = new Date(); + + const maps = getMaps(); + + response.render("report-search", { + headTitle: "Reports", + todayDateString: dateTimeFunctions.dateToString(rightNow), + maps + }); +}; + +export default handler; diff --git a/routes/reports.js b/routes/reports.js index a4db9915..12790006 100644 --- a/routes/reports.js +++ b/routes/reports.js @@ -1,13 +1,7 @@ import { Router } from "express"; +import handler_search from "../handlers/reports-get/search.js"; import handler_reportName from "../handlers/reports-get/reportName.js"; -import * as dateTimeFns from "@cityssm/expressjs-server-js/dateTimeFns.js"; export const router = Router(); -router.get("/", (_request, response) => { - const rightNow = new Date(); - response.render("report-search", { - headTitle: "Reports", - todayDateString: dateTimeFns.dateToString(rightNow) - }); -}); +router.get("/", handler_search); router.all("/:reportName", handler_reportName); export default router; diff --git a/routes/reports.ts b/routes/reports.ts index f2f9f266..e102bff6 100644 --- a/routes/reports.ts +++ b/routes/reports.ts @@ -1,19 +1,11 @@ import { Router } from "express"; +import handler_search from "../handlers/reports-get/search.js"; import handler_reportName from "../handlers/reports-get/reportName.js"; -import * as dateTimeFns from "@cityssm/expressjs-server-js/dateTimeFns.js"; - export const router = Router(); -router.get("/", (_request, response) => { - const rightNow = new Date(); - - response.render("report-search", { - headTitle: "Reports", - todayDateString: dateTimeFns.dateToString(rightNow) - }); -}); +router.get("/", handler_search); router.all("/:reportName", handler_reportName);