diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..7e3fea52 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,2 @@ +*.ejs +*.js \ No newline at end of file diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 00000000..622ac0bf --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,6 @@ +{ + "trailingComma": "none", + "tabWidth": 4, + "semi": true, + "singleQuote": false +} diff --git a/app.js b/app.js index c91c78d7..5216c67f 100644 --- a/app.js +++ b/app.js @@ -131,7 +131,8 @@ app.use((_request, _response, next) => { }); app.use((error, request, response) => { response.locals.message = error.message; - response.locals.error = request.app.get("env") === "development" ? error : {}; + response.locals.error = + request.app.get("env") === "development" ? error : {}; response.status(error.status || 500); response.render("error"); }); diff --git a/app.ts b/app.ts index 5602aeaa..a6d00a73 100644 --- a/app.ts +++ b/app.ts @@ -24,29 +24,23 @@ import * as dateTimeFns from "@cityssm/expressjs-server-js/dateTimeFns.js"; import * as stringFns from "@cityssm/expressjs-server-js/stringFns.js"; import * as htmlFns from "@cityssm/expressjs-server-js/htmlFns.js"; -import { - version -} from "./version.js"; +import { version } from "./version.js"; import * as databaseInitializer from "./helpers/initializer.database.js"; import debug from "debug"; const debugApp = debug("lot-occupancy-system:app"); - /* * INITALIZE THE DATABASE */ - databaseInitializer.initializeDatabase(); - /* * INITIALIZE APP */ - const __dirname = "."; export const app = express(); @@ -70,15 +64,18 @@ app.use((request, _response, next) => { app.use(express.json()); -app.use(express.urlencoded({ - extended: false -})); +app.use( + express.urlencoded({ + extended: false + }) +); app.use(cookieParser()); -app.use(csurf({ - cookie: true -})); - +app.use( + csurf({ + cookie: true + }) +); /* * Rate Limiter @@ -91,12 +88,10 @@ const limiter = rateLimit({ app.use(limiter); - /* * STATIC ROUTES */ - const urlPrefix = configFunctions.getProperty("reverseProxy.urlPrefix"); if (urlPrefix !== "") { @@ -105,48 +100,59 @@ if (urlPrefix !== "") { app.use(urlPrefix, express.static(path.join("public"))); -app.use(urlPrefix + "/lib/fa", - express.static(path.join("node_modules", "@fortawesome", "fontawesome-free"))); +app.use( + urlPrefix + "/lib/fa", + express.static( + path.join("node_modules", "@fortawesome", "fontawesome-free") + ) +); -app.use(urlPrefix + "/lib/cityssm-bulma-webapp-js", - express.static(path.join("node_modules", "@cityssm", "bulma-webapp-js"))); +app.use( + urlPrefix + "/lib/cityssm-bulma-webapp-js", + express.static(path.join("node_modules", "@cityssm", "bulma-webapp-js")) +); -app.use(urlPrefix + "/lib/cityssm-bulma-js", - express.static(path.join("node_modules", "@cityssm", "bulma-js", "dist"))); - -app.use(urlPrefix + "/lib/leaflet", - express.static(path.join("node_modules", "leaflet", "dist"))); +app.use( + urlPrefix + "/lib/cityssm-bulma-js", + express.static(path.join("node_modules", "@cityssm", "bulma-js", "dist")) +); +app.use( + urlPrefix + "/lib/leaflet", + express.static(path.join("node_modules", "leaflet", "dist")) +); /* * SESSION MANAGEMENT */ -const sessionCookieName: string = configFunctions.getProperty("session.cookieName"); +const sessionCookieName: string = + configFunctions.getProperty("session.cookieName"); const FileStoreSession = FileStore(session); // Initialize session -app.use(session({ - store: new FileStoreSession({ - path: "./data/sessions", - logFn: debug("general-licence-manager:session"), - retries: 10 - }), - name: sessionCookieName, - secret: configFunctions.getProperty("session.secret"), - resave: true, - saveUninitialized: false, - rolling: true, - cookie: { - maxAge: configFunctions.getProperty("session.maxAgeMillis"), - sameSite: "strict" - } -})); +app.use( + session({ + store: new FileStoreSession({ + path: "./data/sessions", + logFn: debug("general-licence-manager:session"), + retries: 10 + }), + name: sessionCookieName, + secret: configFunctions.getProperty("session.secret"), + resave: true, + saveUninitialized: false, + rolling: true, + cookie: { + maxAge: configFunctions.getProperty("session.maxAgeMillis"), + sameSite: "strict" + } + }) +); // Clear cookie if no corresponding session app.use((request, response, next) => { - if (request.cookies[sessionCookieName] && !request.session.user) { response.clearCookie(sessionCookieName); } @@ -155,25 +161,27 @@ app.use((request, response, next) => { }); // Redirect logged in users -const sessionChecker = (request: express.Request, response: express.Response, next: express.NextFunction) => { - +const sessionChecker = ( + request: express.Request, + response: express.Response, + next: express.NextFunction +) => { if (request.session.user && request.cookies[sessionCookieName]) { return next(); } - return response.redirect(`${urlPrefix}/login?redirect=${request.originalUrl}`); + return response.redirect( + `${urlPrefix}/login?redirect=${request.originalUrl}` + ); }; - /* * ROUTES */ - // Make the user and config objects available to the templates app.use((request, response, next) => { - response.locals.buildNumber = version; response.locals.user = request.session.user; @@ -184,12 +192,13 @@ app.use((request, response, next) => { response.locals.stringFunctions = stringFns; response.locals.htmlFunctions = htmlFns; - response.locals.urlPrefix = configFunctions.getProperty("reverseProxy.urlPrefix"); + response.locals.urlPrefix = configFunctions.getProperty( + "reverseProxy.urlPrefix" + ); next(); }); - app.get(urlPrefix + "/", sessionChecker, (_request, response) => { response.redirect(urlPrefix + "/dashboard"); }); @@ -211,40 +220,41 @@ app.all(urlPrefix + "/keepAlive", (_request, response) => { app.use(urlPrefix + "/login", routerLogin); app.get(urlPrefix + "/logout", (request, response) => { - if (request.session.user && request.cookies[sessionCookieName]) { - // eslint-disable-next-line unicorn/no-null request.session.destroy(null); request.session = undefined; response.clearCookie(sessionCookieName); response.redirect(urlPrefix + "/"); - } else { response.redirect(urlPrefix + "/login"); } }); - // Catch 404 and forward to error handler app.use((_request, _response, next) => { next(createError(404)); }); // Error handler -app.use((error: { - status: number;message: string - }, - request: express.Request, response: express.Response) => { +app.use( + ( + error: { + status: number; + message: string; + }, + request: express.Request, + response: express.Response + ) => { + // Set locals, only providing error in development + response.locals.message = error.message; + response.locals.error = + request.app.get("env") === "development" ? error : {}; - // Set locals, only providing error in development - response.locals.message = error.message; - response.locals.error = request.app.get("env") === "development" ? error : {}; + // Render the error page + response.status(error.status || 500); + response.render("error"); + } +); - // Render the error page - response.status(error.status || 500); - response.render("error"); -}); - - -export default app; \ No newline at end of file +export default app; diff --git a/cypress.config.js b/cypress.config.js index 52a52c89..bc81052e 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -1,9 +1,9 @@ import { defineConfig } from "cypress"; export default defineConfig({ e2e: { - "baseUrl": "http://localhost:7000", - "specPattern": "cypress/e2e/**/*.cy.ts", - "supportFile": false, - "projectId": "xya1fn" + baseUrl: "http://localhost:7000", + specPattern: "cypress/e2e/**/*.cy.ts", + supportFile: false, + projectId: "xya1fn" } }); diff --git a/cypress.config.ts b/cypress.config.ts index 015850bf..4d91cb24 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -2,12 +2,11 @@ import { defineConfig } from "cypress"; - export default defineConfig({ - e2e: { - "baseUrl": "http://localhost:7000", - "specPattern": "cypress/e2e/**/*.cy.ts", - "supportFile": false, - "projectId": "xya1fn" - } -}); \ No newline at end of file + e2e: { + baseUrl: "http://localhost:7000", + specPattern: "cypress/e2e/**/*.cy.ts", + supportFile: false, + projectId: "xya1fn" + } +}); diff --git a/gulpfile.js b/gulpfile.js index 03052c3d..aa104277 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,19 +1,21 @@ import gulp from "gulp"; import changed from "gulp-changed"; import minify from "gulp-minify"; -import dartSass from 'sass'; -import gulpSass from 'gulp-sass'; +import dartSass from "sass"; +import gulpSass from "gulp-sass"; const sass = gulpSass(dartSass); const publicSCSSDestination = "public/stylesheets"; const publicSCSSFunction = () => { - return gulp.src("public-scss/*.scss") - .pipe(sass({ outputStyle: 'compressed' }).on('error', sass.logError)) + return gulp + .src("public-scss/*.scss") + .pipe(sass({ outputStyle: "compressed" }).on("error", sass.logError)) .pipe(gulp.dest(publicSCSSDestination)); }; gulp.task("public-scss", publicSCSSFunction); const publicJavascriptsDestination = "public/javascripts"; const publicJavascriptsMinFunction = () => { - return gulp.src("public-typescript/*.js", { allowEmpty: true }) + return gulp + .src("public-typescript/*.js", { allowEmpty: true }) .pipe(changed(publicJavascriptsDestination, { extension: ".min.js" })) diff --git a/gulpfile.ts b/gulpfile.ts index 3ea07d0c..4ba13fc3 100644 --- a/gulpfile.ts +++ b/gulpfile.ts @@ -4,8 +4,8 @@ import gulp from "gulp"; import changed from "gulp-changed"; import minify from "gulp-minify"; -import dartSass from 'sass'; -import gulpSass from 'gulp-sass'; +import dartSass from "sass"; +import gulpSass from "gulp-sass"; const sass = gulpSass(dartSass); /* @@ -15,10 +15,10 @@ const sass = gulpSass(dartSass); const publicSCSSDestination = "public/stylesheets"; const publicSCSSFunction = () => { - - return gulp.src("public-scss/*.scss") - .pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError)) - .pipe(gulp.dest(publicSCSSDestination)); + return gulp + .src("public-scss/*.scss") + .pipe(sass({ outputStyle: "compressed" }).on("error", sass.logError)) + .pipe(gulp.dest(publicSCSSDestination)); }; gulp.task("public-scss", publicSCSSFunction); @@ -30,13 +30,15 @@ gulp.task("public-scss", publicSCSSFunction); const publicJavascriptsDestination = "public/javascripts"; const publicJavascriptsMinFunction = () => { - - return gulp.src("public-typescript/*.js", { allowEmpty: true }) - .pipe(changed(publicJavascriptsDestination, { - extension: ".min.js" - })) - .pipe(minify({ noSource: true, ext: { min: ".min.js" } })) - .pipe(gulp.dest(publicJavascriptsDestination)); + return gulp + .src("public-typescript/*.js", { allowEmpty: true }) + .pipe( + changed(publicJavascriptsDestination, { + extension: ".min.js" + }) + ) + .pipe(minify({ noSource: true, ext: { min: ".min.js" } })) + .pipe(gulp.dest(publicJavascriptsDestination)); }; gulp.task("public-javascript-min", publicJavascriptsMinFunction); @@ -46,8 +48,8 @@ gulp.task("public-javascript-min", publicJavascriptsMinFunction); */ const watchFunction = () => { - gulp.watch("public-scss/*.scss", publicSCSSFunction); - gulp.watch("public-typescript/*.js", publicJavascriptsMinFunction); + gulp.watch("public-scss/*.scss", publicSCSSFunction); + gulp.watch("public-typescript/*.js", publicJavascriptsMinFunction); }; gulp.task("watch", watchFunction); @@ -57,7 +59,7 @@ gulp.task("watch", watchFunction); */ gulp.task("default", () => { - publicJavascriptsMinFunction(); - publicSCSSFunction(); - watchFunction(); + publicJavascriptsMinFunction(); + publicSCSSFunction(); + watchFunction(); }); diff --git a/handlers/admin-get/fees.ts b/handlers/admin-get/fees.ts index 36e85284..eef189c1 100644 --- a/handlers/admin-get/fees.ts +++ b/handlers/admin-get/fees.ts @@ -1,19 +1,19 @@ -import type { - RequestHandler -} from "express"; - -import { getLotTypes, getOccupancyTypes } from "../../helpers/functions.cache.js"; +import type { RequestHandler } from "express"; import { - getFeeCategories -} from "../../helpers/lotOccupancyDB/getFeeCategories.js"; + getLotTypes, + getOccupancyTypes +} from "../../helpers/functions.cache.js"; +import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories.js"; export const handler: RequestHandler = (_request, response) => { - - const feeCategories = getFeeCategories({}, { - includeFees: true - }); + const feeCategories = getFeeCategories( + {}, + { + includeFees: true + } + ); const occupancyTypes = getOccupancyTypes(); const lotTypes = getLotTypes(); @@ -26,5 +26,4 @@ export const handler: RequestHandler = (_request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-get/tables.ts b/handlers/admin-get/tables.ts index 9b558dde..6b074e52 100644 --- a/handlers/admin-get/tables.ts +++ b/handlers/admin-get/tables.ts @@ -1,12 +1,12 @@ -import type { - RequestHandler -} from "express"; - -import { getLotOccupantTypes, getLotStatuses, getWorkOrderTypes } from "../../helpers/functions.cache.js"; +import type { RequestHandler } from "express"; +import { + getLotOccupantTypes, + getLotStatuses, + getWorkOrderTypes +} from "../../helpers/functions.cache.js"; export const handler: RequestHandler = (_request, response) => { - const workOrderTypes = getWorkOrderTypes(); const lotStatuses = getLotStatuses(); const lotOccupantTypes = getLotOccupantTypes(); @@ -19,5 +19,4 @@ export const handler: RequestHandler = (_request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doAddFee.ts b/handlers/admin-post/doAddFee.ts index e104edf6..8e94e922 100644 --- a/handlers/admin-post/doAddFee.ts +++ b/handlers/admin-post/doAddFee.ts @@ -1,24 +1,18 @@ -import type { - RequestHandler -} from "express"; - -import { - addFee -} from "../../helpers/lotOccupancyDB/addFee.js"; - -import { - getFeeCategories -} from "../../helpers/lotOccupancyDB/getFeeCategories.js"; +import type { RequestHandler } from "express"; +import { addFee } from "../../helpers/lotOccupancyDB/addFee.js"; +import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories.js"; export const handler: RequestHandler = async (request, response) => { - const feeId = addFee(request.body, request.session); - const feeCategories = getFeeCategories({}, { - includeFees: true - }); + const feeCategories = getFeeCategories( + {}, + { + includeFees: true + } + ); response.json({ success: true, @@ -27,5 +21,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doAddFeeCategory.ts b/handlers/admin-post/doAddFeeCategory.ts index d3438e82..bb80eafd 100644 --- a/handlers/admin-post/doAddFeeCategory.ts +++ b/handlers/admin-post/doAddFeeCategory.ts @@ -1,24 +1,18 @@ -import type { - RequestHandler -} from "express"; - -import { - addFeeCategory -} from "../../helpers/lotOccupancyDB/addFeeCategory.js"; - -import { - getFeeCategories -} from "../../helpers/lotOccupancyDB/getFeeCategories.js"; +import type { RequestHandler } from "express"; +import { addFeeCategory } from "../../helpers/lotOccupancyDB/addFeeCategory.js"; +import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories.js"; export const handler: RequestHandler = async (request, response) => { - const feeCategoryId = addFeeCategory(request.body, request.session); - const feeCategories = getFeeCategories({}, { - includeFees: true - }); + const feeCategories = getFeeCategories( + {}, + { + includeFees: true + } + ); response.json({ success: true, @@ -27,5 +21,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doAddLotOccupantType.ts b/handlers/admin-post/doAddLotOccupantType.ts index b13b68f7..cc6c3ddd 100644 --- a/handlers/admin-post/doAddLotOccupantType.ts +++ b/handlers/admin-post/doAddLotOccupantType.ts @@ -1,18 +1,10 @@ -import type { - RequestHandler -} from "express"; +import type { RequestHandler } from "express"; -import { - addLotOccupantType -} from "../../helpers/lotOccupancyDB/addLotOccupantType.js"; - -import { - getLotOccupantTypes -} from "../../helpers/functions.cache.js"; +import { addLotOccupantType } from "../../helpers/lotOccupancyDB/addLotOccupantType.js"; +import { getLotOccupantTypes } from "../../helpers/functions.cache.js"; export const handler: RequestHandler = async (request, response) => { - const lotOccupantTypeId = addLotOccupantType(request.body, request.session); const lotOccupantTypes = getLotOccupantTypes(); @@ -24,5 +16,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doAddLotStatus.ts b/handlers/admin-post/doAddLotStatus.ts index 29a3d042..e163b9cc 100644 --- a/handlers/admin-post/doAddLotStatus.ts +++ b/handlers/admin-post/doAddLotStatus.ts @@ -1,18 +1,10 @@ -import type { - RequestHandler -} from "express"; +import type { RequestHandler } from "express"; -import { - addLotStatus -} from "../../helpers/lotOccupancyDB/addLotStatus.js"; - -import { - getLotStatuses -} from "../../helpers/functions.cache.js"; +import { addLotStatus } from "../../helpers/lotOccupancyDB/addLotStatus.js"; +import { getLotStatuses } from "../../helpers/functions.cache.js"; export const handler: RequestHandler = async (request, response) => { - const lotStatusId = addLotStatus(request.body, request.session); const lotStatuses = getLotStatuses(); @@ -24,5 +16,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doAddWorkOrderType.ts b/handlers/admin-post/doAddWorkOrderType.ts index ebbf65d0..42df698a 100644 --- a/handlers/admin-post/doAddWorkOrderType.ts +++ b/handlers/admin-post/doAddWorkOrderType.ts @@ -1,18 +1,10 @@ -import type { - RequestHandler -} from "express"; +import type { RequestHandler } from "express"; -import { - addWorkOrderType -} from "../../helpers/lotOccupancyDB/addWorkOrderType.js"; - -import { - getWorkOrderTypes -} from "../../helpers/functions.cache.js"; +import { addWorkOrderType } from "../../helpers/lotOccupancyDB/addWorkOrderType.js"; +import { getWorkOrderTypes } from "../../helpers/functions.cache.js"; export const handler: RequestHandler = async (request, response) => { - const workOrderTypeId = addWorkOrderType(request.body, request.session); const workOrderTypes = getWorkOrderTypes(); @@ -24,5 +16,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doDeleteFee.ts b/handlers/admin-post/doDeleteFee.ts index b5ce4442..0ea9f946 100644 --- a/handlers/admin-post/doDeleteFee.ts +++ b/handlers/admin-post/doDeleteFee.ts @@ -1,24 +1,18 @@ -import type { - RequestHandler -} from "express"; - -import { - deleteFee -} from "../../helpers/lotOccupancyDB/deleteFee.js"; - -import { - getFeeCategories -} from "../../helpers/lotOccupancyDB/getFeeCategories.js"; +import type { RequestHandler } from "express"; +import { deleteFee } from "../../helpers/lotOccupancyDB/deleteFee.js"; +import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories.js"; export const handler: RequestHandler = async (request, response) => { - const success = deleteFee(request.body.feeId, request.session); - const feeCategories = getFeeCategories({}, { - includeFees: true - }); + const feeCategories = getFeeCategories( + {}, + { + includeFees: true + } + ); response.json({ success, @@ -26,5 +20,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doDeleteFeeCategory.ts b/handlers/admin-post/doDeleteFeeCategory.ts index e82af450..592629ed 100644 --- a/handlers/admin-post/doDeleteFeeCategory.ts +++ b/handlers/admin-post/doDeleteFeeCategory.ts @@ -1,24 +1,21 @@ -import type { - RequestHandler -} from "express"; - -import { - deleteFeeCategory -} from "../../helpers/lotOccupancyDB/deleteFeeCategory.js"; - -import { - getFeeCategories -} from "../../helpers/lotOccupancyDB/getFeeCategories.js"; +import type { RequestHandler } from "express"; +import { deleteFeeCategory } from "../../helpers/lotOccupancyDB/deleteFeeCategory.js"; +import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories.js"; export const handler: RequestHandler = async (request, response) => { + const success = deleteFeeCategory( + request.body.feeCategoryId, + request.session + ); - const success = deleteFeeCategory(request.body.feeCategoryId, request.session); - - const feeCategories = getFeeCategories({}, { - includeFees: true - }); + const feeCategories = getFeeCategories( + {}, + { + includeFees: true + } + ); response.json({ success, @@ -26,5 +23,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doDeleteLotOccupantType.ts b/handlers/admin-post/doDeleteLotOccupantType.ts index 7df6b0ad..7231c33f 100644 --- a/handlers/admin-post/doDeleteLotOccupantType.ts +++ b/handlers/admin-post/doDeleteLotOccupantType.ts @@ -1,19 +1,14 @@ -import type { - RequestHandler -} from "express"; +import type { RequestHandler } from "express"; -import { - deleteLotOccupantType -} from "../../helpers/lotOccupancyDB/deleteLotOccupantType.js"; - -import { - getLotOccupantTypes -} from "../../helpers/functions.cache.js"; +import { deleteLotOccupantType } from "../../helpers/lotOccupancyDB/deleteLotOccupantType.js"; +import { getLotOccupantTypes } from "../../helpers/functions.cache.js"; export const handler: RequestHandler = async (request, response) => { - - const success = deleteLotOccupantType(request.body.lotOccupantTypeId, request.session); + const success = deleteLotOccupantType( + request.body.lotOccupantTypeId, + request.session + ); const lotOccupantTypes = getLotOccupantTypes(); @@ -23,5 +18,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doDeleteLotStatus.ts b/handlers/admin-post/doDeleteLotStatus.ts index ddd55799..2651119a 100644 --- a/handlers/admin-post/doDeleteLotStatus.ts +++ b/handlers/admin-post/doDeleteLotStatus.ts @@ -1,18 +1,10 @@ -import type { - RequestHandler -} from "express"; +import type { RequestHandler } from "express"; -import { - deleteLotStatus -} from "../../helpers/lotOccupancyDB/deleteLotStatus.js"; - -import { - getLotStatuses -} from "../../helpers/functions.cache.js"; +import { deleteLotStatus } from "../../helpers/lotOccupancyDB/deleteLotStatus.js"; +import { getLotStatuses } from "../../helpers/functions.cache.js"; export const handler: RequestHandler = async (request, response) => { - const success = deleteLotStatus(request.body.lotStatusId, request.session); const lotStatuses = getLotStatuses(); @@ -23,5 +15,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doDeleteWorkOrderType.ts b/handlers/admin-post/doDeleteWorkOrderType.ts index ca5be76d..10d83de1 100644 --- a/handlers/admin-post/doDeleteWorkOrderType.ts +++ b/handlers/admin-post/doDeleteWorkOrderType.ts @@ -1,19 +1,14 @@ -import type { - RequestHandler -} from "express"; +import type { RequestHandler } from "express"; -import { - deleteWorkOrderType -} from "../../helpers/lotOccupancyDB/deleteWorkOrderType.js"; - -import { - getWorkOrderTypes -} from "../../helpers/functions.cache.js"; +import { deleteWorkOrderType } from "../../helpers/lotOccupancyDB/deleteWorkOrderType.js"; +import { getWorkOrderTypes } from "../../helpers/functions.cache.js"; export const handler: RequestHandler = async (request, response) => { - - const success = deleteWorkOrderType(request.body.workOrderTypeId, request.session); + const success = deleteWorkOrderType( + request.body.workOrderTypeId, + request.session + ); const workOrderTypes = getWorkOrderTypes(); @@ -23,5 +18,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doMoveFeeCategoryDown.ts b/handlers/admin-post/doMoveFeeCategoryDown.ts index 3196bc1d..36d885ff 100644 --- a/handlers/admin-post/doMoveFeeCategoryDown.ts +++ b/handlers/admin-post/doMoveFeeCategoryDown.ts @@ -1,23 +1,18 @@ -import type { - RequestHandler -} from "express"; +import type { RequestHandler } from "express"; -import { - moveFeeCategoryDown -} from "../../helpers/lotOccupancyDB/moveFeeCategoryDown.js"; - -import { - getFeeCategories -} from "../../helpers/lotOccupancyDB/getFeeCategories.js"; +import { moveFeeCategoryDown } from "../../helpers/lotOccupancyDB/moveFeeCategoryDown.js"; +import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories.js"; export const handler: RequestHandler = async (request, response) => { - const success = moveFeeCategoryDown(request.body.feeCategoryId); - const feeCategories = getFeeCategories({}, { - includeFees: true - }); + const feeCategories = getFeeCategories( + {}, + { + includeFees: true + } + ); response.json({ success, @@ -25,5 +20,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doMoveFeeCategoryUp.ts b/handlers/admin-post/doMoveFeeCategoryUp.ts index 194b4964..ab5c485e 100644 --- a/handlers/admin-post/doMoveFeeCategoryUp.ts +++ b/handlers/admin-post/doMoveFeeCategoryUp.ts @@ -1,23 +1,18 @@ -import type { - RequestHandler -} from "express"; +import type { RequestHandler } from "express"; -import { - moveFeeCategoryUp -} from "../../helpers/lotOccupancyDB/moveFeeCategoryUp.js"; - -import { - getFeeCategories -} from "../../helpers/lotOccupancyDB/getFeeCategories.js"; +import { moveFeeCategoryUp } from "../../helpers/lotOccupancyDB/moveFeeCategoryUp.js"; +import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories.js"; export const handler: RequestHandler = async (request, response) => { - const success = moveFeeCategoryUp(request.body.feeCategoryId); - const feeCategories = getFeeCategories({}, { - includeFees: true - }); + const feeCategories = getFeeCategories( + {}, + { + includeFees: true + } + ); response.json({ success, @@ -25,5 +20,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doMoveFeeDown.ts b/handlers/admin-post/doMoveFeeDown.ts index e57252a4..d1dcb369 100644 --- a/handlers/admin-post/doMoveFeeDown.ts +++ b/handlers/admin-post/doMoveFeeDown.ts @@ -1,23 +1,18 @@ -import type { - RequestHandler -} from "express"; +import type { RequestHandler } from "express"; -import { - moveFeeDown -} from "../../helpers/lotOccupancyDB/moveFeeDown.js"; - -import { - getFeeCategories -} from "../../helpers/lotOccupancyDB/getFeeCategories.js"; +import { moveFeeDown } from "../../helpers/lotOccupancyDB/moveFeeDown.js"; +import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories.js"; export const handler: RequestHandler = async (request, response) => { - const success = moveFeeDown(request.body.feeId); - const feeCategories = getFeeCategories({}, { - includeFees: true - }); + const feeCategories = getFeeCategories( + {}, + { + includeFees: true + } + ); response.json({ success, @@ -25,5 +20,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doMoveFeeUp.ts b/handlers/admin-post/doMoveFeeUp.ts index e1fd6f9a..4e882ec8 100644 --- a/handlers/admin-post/doMoveFeeUp.ts +++ b/handlers/admin-post/doMoveFeeUp.ts @@ -1,23 +1,18 @@ -import type { - RequestHandler -} from "express"; +import type { RequestHandler } from "express"; -import { - moveFeeUp -} from "../../helpers/lotOccupancyDB/moveFeeUp.js"; - -import { - getFeeCategories -} from "../../helpers/lotOccupancyDB/getFeeCategories.js"; +import { moveFeeUp } from "../../helpers/lotOccupancyDB/moveFeeUp.js"; +import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories.js"; export const handler: RequestHandler = async (request, response) => { - const success = moveFeeUp(request.body.feeId); - const feeCategories = getFeeCategories({}, { - includeFees: true - }); + const feeCategories = getFeeCategories( + {}, + { + includeFees: true + } + ); response.json({ success, @@ -25,5 +20,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doMoveLotOccupantTypeDown.ts b/handlers/admin-post/doMoveLotOccupantTypeDown.ts index a2709d40..f0100cbc 100644 --- a/handlers/admin-post/doMoveLotOccupantTypeDown.ts +++ b/handlers/admin-post/doMoveLotOccupantTypeDown.ts @@ -1,18 +1,10 @@ -import type { - RequestHandler -} from "express"; +import type { RequestHandler } from "express"; -import { - moveLotOccupantTypeDown -} from "../../helpers/lotOccupancyDB/moveLotOccupantTypeDown.js"; - -import { - getLotOccupantTypes -} from "../../helpers/functions.cache.js"; +import { moveLotOccupantTypeDown } from "../../helpers/lotOccupancyDB/moveLotOccupantTypeDown.js"; +import { getLotOccupantTypes } from "../../helpers/functions.cache.js"; export const handler: RequestHandler = async (request, response) => { - const success = moveLotOccupantTypeDown(request.body.lotOccupantTypeId); const lotOccupantTypes = getLotOccupantTypes(); @@ -23,5 +15,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doMoveLotOccupantTypeUp.ts b/handlers/admin-post/doMoveLotOccupantTypeUp.ts index 63cc2a6e..52a687f7 100644 --- a/handlers/admin-post/doMoveLotOccupantTypeUp.ts +++ b/handlers/admin-post/doMoveLotOccupantTypeUp.ts @@ -1,18 +1,10 @@ -import type { - RequestHandler -} from "express"; +import type { RequestHandler } from "express"; -import { - moveLotOccupantTypeUp -} from "../../helpers/lotOccupancyDB/moveLotOccupantTypeUp.js"; - -import { - getLotOccupantTypes -} from "../../helpers/functions.cache.js"; +import { moveLotOccupantTypeUp } from "../../helpers/lotOccupancyDB/moveLotOccupantTypeUp.js"; +import { getLotOccupantTypes } from "../../helpers/functions.cache.js"; export const handler: RequestHandler = async (request, response) => { - const success = moveLotOccupantTypeUp(request.body.lotOccupantTypeId); const lotOccupantTypes = getLotOccupantTypes(); @@ -23,5 +15,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doMoveLotStatusDown.ts b/handlers/admin-post/doMoveLotStatusDown.ts index 19219a0d..3208eb10 100644 --- a/handlers/admin-post/doMoveLotStatusDown.ts +++ b/handlers/admin-post/doMoveLotStatusDown.ts @@ -1,18 +1,10 @@ -import type { - RequestHandler -} from "express"; +import type { RequestHandler } from "express"; -import { - moveLotStatusDown -} from "../../helpers/lotOccupancyDB/moveLotStatusDown.js"; - -import { - getLotStatuses -} from "../../helpers/functions.cache.js"; +import { moveLotStatusDown } from "../../helpers/lotOccupancyDB/moveLotStatusDown.js"; +import { getLotStatuses } from "../../helpers/functions.cache.js"; export const handler: RequestHandler = async (request, response) => { - const success = moveLotStatusDown(request.body.lotStatusId); const lotStatuses = getLotStatuses(); @@ -23,5 +15,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doMoveLotStatusUp.ts b/handlers/admin-post/doMoveLotStatusUp.ts index 3a28f84a..6afeb108 100644 --- a/handlers/admin-post/doMoveLotStatusUp.ts +++ b/handlers/admin-post/doMoveLotStatusUp.ts @@ -1,18 +1,10 @@ -import type { - RequestHandler -} from "express"; +import type { RequestHandler } from "express"; -import { - moveLotStatusUp -} from "../../helpers/lotOccupancyDB/moveLotStatusUp.js"; - -import { - getLotStatuses -} from "../../helpers/functions.cache.js"; +import { moveLotStatusUp } from "../../helpers/lotOccupancyDB/moveLotStatusUp.js"; +import { getLotStatuses } from "../../helpers/functions.cache.js"; export const handler: RequestHandler = async (request, response) => { - const success = moveLotStatusUp(request.body.lotStatusId); const lotStatuses = getLotStatuses(); @@ -23,5 +15,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doMoveWorkOrderTypeDown.ts b/handlers/admin-post/doMoveWorkOrderTypeDown.ts index 8b66bd41..a553269d 100644 --- a/handlers/admin-post/doMoveWorkOrderTypeDown.ts +++ b/handlers/admin-post/doMoveWorkOrderTypeDown.ts @@ -1,18 +1,10 @@ -import type { - RequestHandler -} from "express"; +import type { RequestHandler } from "express"; -import { - moveWorkOrderTypeDown -} from "../../helpers/lotOccupancyDB/moveWorkOrderTypeDown.js"; - -import { - getWorkOrderTypes -} from "../../helpers/functions.cache.js"; +import { moveWorkOrderTypeDown } from "../../helpers/lotOccupancyDB/moveWorkOrderTypeDown.js"; +import { getWorkOrderTypes } from "../../helpers/functions.cache.js"; export const handler: RequestHandler = async (request, response) => { - const success = moveWorkOrderTypeDown(request.body.workOrderTypeId); const workOrderTypes = getWorkOrderTypes(); @@ -23,5 +15,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doMoveWorkOrderTypeUp.ts b/handlers/admin-post/doMoveWorkOrderTypeUp.ts index 428e2531..5826a907 100644 --- a/handlers/admin-post/doMoveWorkOrderTypeUp.ts +++ b/handlers/admin-post/doMoveWorkOrderTypeUp.ts @@ -1,18 +1,10 @@ -import type { - RequestHandler -} from "express"; +import type { RequestHandler } from "express"; -import { - moveWorkOrderTypeUp -} from "../../helpers/lotOccupancyDB/moveWorkOrderTypeUp.js"; - -import { - getWorkOrderTypes -} from "../../helpers/functions.cache.js"; +import { moveWorkOrderTypeUp } from "../../helpers/lotOccupancyDB/moveWorkOrderTypeUp.js"; +import { getWorkOrderTypes } from "../../helpers/functions.cache.js"; export const handler: RequestHandler = async (request, response) => { - const success = moveWorkOrderTypeUp(request.body.workOrderTypeId); const workOrderTypes = getWorkOrderTypes(); @@ -23,5 +15,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doUpdateFee.ts b/handlers/admin-post/doUpdateFee.ts index a91bbb1e..1d3a3074 100644 --- a/handlers/admin-post/doUpdateFee.ts +++ b/handlers/admin-post/doUpdateFee.ts @@ -1,24 +1,18 @@ -import type { - RequestHandler -} from "express"; - -import { - updateFee -} from "../../helpers/lotOccupancyDB/updateFee.js"; - -import { - getFeeCategories -} from "../../helpers/lotOccupancyDB/getFeeCategories.js"; +import type { RequestHandler } from "express"; +import { updateFee } from "../../helpers/lotOccupancyDB/updateFee.js"; +import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories.js"; export const handler: RequestHandler = async (request, response) => { - const success = updateFee(request.body, request.session); - const feeCategories = getFeeCategories({}, { - includeFees: true - }); + const feeCategories = getFeeCategories( + {}, + { + includeFees: true + } + ); response.json({ success, @@ -26,5 +20,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doUpdateFeeCategory.ts b/handlers/admin-post/doUpdateFeeCategory.ts index 52f9ba53..b95ff2e3 100644 --- a/handlers/admin-post/doUpdateFeeCategory.ts +++ b/handlers/admin-post/doUpdateFeeCategory.ts @@ -1,24 +1,18 @@ -import type { - RequestHandler -} from "express"; - -import { - updateFeeCategory -} from "../../helpers/lotOccupancyDB/updateFeeCategory.js"; - -import { - getFeeCategories -} from "../../helpers/lotOccupancyDB/getFeeCategories.js"; +import type { RequestHandler } from "express"; +import { updateFeeCategory } from "../../helpers/lotOccupancyDB/updateFeeCategory.js"; +import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories.js"; export const handler: RequestHandler = async (request, response) => { - const success = updateFeeCategory(request.body, request.session); - const feeCategories = getFeeCategories({}, { - includeFees: true - }); + const feeCategories = getFeeCategories( + {}, + { + includeFees: true + } + ); response.json({ success, @@ -26,5 +20,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doUpdateLotOccupantType.ts b/handlers/admin-post/doUpdateLotOccupantType.ts index b103cc20..0144f562 100644 --- a/handlers/admin-post/doUpdateLotOccupantType.ts +++ b/handlers/admin-post/doUpdateLotOccupantType.ts @@ -1,18 +1,10 @@ -import type { - RequestHandler -} from "express"; +import type { RequestHandler } from "express"; -import { - updateLotOccupantType -} from "../../helpers/lotOccupancyDB/updateLotOccupantType.js"; - -import { - getLotOccupantTypes -} from "../../helpers/functions.cache.js"; +import { updateLotOccupantType } from "../../helpers/lotOccupancyDB/updateLotOccupantType.js"; +import { getLotOccupantTypes } from "../../helpers/functions.cache.js"; export const handler: RequestHandler = async (request, response) => { - const success = updateLotOccupantType(request.body, request.session); const lotOccupantTypes = getLotOccupantTypes(); @@ -23,5 +15,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doUpdateLotStatus.ts b/handlers/admin-post/doUpdateLotStatus.ts index c4046989..a2bf1515 100644 --- a/handlers/admin-post/doUpdateLotStatus.ts +++ b/handlers/admin-post/doUpdateLotStatus.ts @@ -1,18 +1,10 @@ -import type { - RequestHandler -} from "express"; +import type { RequestHandler } from "express"; -import { - updateLotStatus -} from "../../helpers/lotOccupancyDB/updateLotStatus.js"; - -import { - getLotStatuses -} from "../../helpers/functions.cache.js"; +import { updateLotStatus } from "../../helpers/lotOccupancyDB/updateLotStatus.js"; +import { getLotStatuses } from "../../helpers/functions.cache.js"; export const handler: RequestHandler = async (request, response) => { - const success = updateLotStatus(request.body, request.session); const lotStatuses = getLotStatuses(); @@ -23,5 +15,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doUpdateWorkOrderType.ts b/handlers/admin-post/doUpdateWorkOrderType.ts index f5cff47a..e43646d8 100644 --- a/handlers/admin-post/doUpdateWorkOrderType.ts +++ b/handlers/admin-post/doUpdateWorkOrderType.ts @@ -1,18 +1,10 @@ -import type { - RequestHandler -} from "express"; +import type { RequestHandler } from "express"; -import { - updateWorkOrderType -} from "../../helpers/lotOccupancyDB/updateWorkOrderType.js"; - -import { - getWorkOrderTypes -} from "../../helpers/functions.cache.js"; +import { updateWorkOrderType } from "../../helpers/lotOccupancyDB/updateWorkOrderType.js"; +import { getWorkOrderTypes } from "../../helpers/functions.cache.js"; export const handler: RequestHandler = async (request, response) => { - const success = updateWorkOrderType(request.body, request.session); const workOrderTypes = getWorkOrderTypes(); @@ -23,5 +15,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/public-typescript/adminFees.js b/public-typescript/adminFees.js index 84daa4b4..97bbc899 100644 --- a/public-typescript/adminFees.js +++ b/public-typescript/adminFees.js @@ -8,53 +8,58 @@ Object.defineProperty(exports, "__esModule", { value: true }); delete exports.feeCategories; const renderFeeCategories = () => { if (feeCategories.length === 0) { - feeCategoriesContainerElement.innerHTML = "
"; + feeCategoriesContainerElement.innerHTML = + '"; return; } feeCategoriesContainerElement.innerHTML = ""; for (const feeCategory of feeCategories) { const feeCategoryContainerElement = document.createElement("section"); - feeCategoryContainerElement.className = "container--feeCategory mb-5"; - feeCategoryContainerElement.dataset.feeCategoryId = feeCategory.feeCategoryId.toString(); - feeCategoryContainerElement.insertAdjacentHTML("beforeend", "