diff --git a/bin/www.js b/bin/www.js index cf6aef6f..3799adae 100644 --- a/bin/www.js +++ b/bin/www.js @@ -20,7 +20,7 @@ cluster.setupPrimary(clusterSettings); const activeWorkers = new Map(); for (let index = 0; index < processCount; index += 1) { const worker = cluster.fork(); - activeWorkers.set(worker.process.pid, worker); + activeWorkers.set(worker.process.pid ?? 0, worker); } cluster.on('message', (worker, message) => { for (const [pid, activeWorker] of activeWorkers.entries()) { @@ -31,9 +31,9 @@ cluster.on('message', (worker, message) => { worker.send(message); } }); -cluster.on('exit', (worker, code, signal) => { - debug(`Worker ${worker.process.pid.toString()} has been killed`); - activeWorkers.delete(worker.process.pid); +cluster.on('exit', (worker) => { + debug(`Worker ${(worker.process.pid ?? 0).toString()} has been killed`); + activeWorkers.delete(worker.process.pid ?? 0); debug('Starting another worker'); cluster.fork(); }); diff --git a/bin/www.ts b/bin/www.ts index ef779364..d79c91a1 100644 --- a/bin/www.ts +++ b/bin/www.ts @@ -37,7 +37,7 @@ const activeWorkers = new Map() for (let index = 0; index < processCount; index += 1) { const worker = cluster.fork() - activeWorkers.set(worker.process.pid!, worker) + activeWorkers.set(worker.process.pid ?? 0, worker) } cluster.on('message', (worker, message: WorkerMessage) => { @@ -51,9 +51,9 @@ cluster.on('message', (worker, message: WorkerMessage) => { } }) -cluster.on('exit', (worker, code, signal) => { - debug(`Worker ${worker.process.pid!.toString()} has been killed`) - activeWorkers.delete(worker.process.pid!) +cluster.on('exit', (worker) => { + debug(`Worker ${(worker.process.pid ?? 0).toString()} has been killed`) + activeWorkers.delete(worker.process.pid ?? 0) debug('Starting another worker') cluster.fork() diff --git a/database/addLotOccupancyFee.js b/database/addLotOccupancyFee.js index f5eb60ab..940ae635 100644 --- a/database/addLotOccupancyFee.js +++ b/database/addLotOccupancyFee.js @@ -9,7 +9,7 @@ export async function addLotOccupancyFee(lotOccupancyFeeForm, user) { let taxAmount; if ((lotOccupancyFeeForm.feeAmount ?? '') === '') { const lotOccupancy = (await getLotOccupancy(lotOccupancyFeeForm.lotOccupancyId)); - const fee = await getFee(lotOccupancyFeeForm.feeId); + const fee = (await getFee(lotOccupancyFeeForm.feeId)); feeAmount = calculateFeeAmount(fee, lotOccupancy); taxAmount = calculateTaxAmount(fee, feeAmount); } diff --git a/database/addLotOccupancyFee.ts b/database/addLotOccupancyFee.ts index 74843b92..e0f04b52 100644 --- a/database/addLotOccupancyFee.ts +++ b/database/addLotOccupancyFee.ts @@ -1,5 +1,8 @@ -import type { LotOccupancy } from '../types/recordTypes.js' -import { calculateFeeAmount, calculateTaxAmount } from '../helpers/functions.fee.js' +import { + calculateFeeAmount, + calculateTaxAmount +} from '../helpers/functions.fee.js' +import type { Fee, LotOccupancy } from '../types/recordTypes.js' import { getFee } from './getFee.js' import { getLotOccupancy } from './getLotOccupancy.js' @@ -30,7 +33,7 @@ export async function addLotOccupancyFee( lotOccupancyFeeForm.lotOccupancyId )) as LotOccupancy - const fee = await getFee(lotOccupancyFeeForm.feeId) + const fee = (await getFee(lotOccupancyFeeForm.feeId)) as Fee feeAmount = calculateFeeAmount(fee, lotOccupancy) taxAmount = calculateTaxAmount(fee, feeAmount) diff --git a/database/getLotOccupancies.ts b/database/getLotOccupancies.ts index 37f1fc18..2f75902a 100644 --- a/database/getLotOccupancies.ts +++ b/database/getLotOccupancies.ts @@ -136,14 +136,14 @@ async function addInclusions( ): Promise { if (options.includeFees) { lotOccupancy.lotOccupancyFees = await getLotOccupancyFees( - lotOccupancy.lotOccupancyId!, + lotOccupancy.lotOccupancyId, database ) } if (options.includeTransactions) { lotOccupancy.lotOccupancyTransactions = await getLotOccupancyTransactions( - lotOccupancy.lotOccupancyId!, + lotOccupancy.lotOccupancyId, { includeIntegrations: false }, database ) @@ -151,7 +151,7 @@ async function addInclusions( if (options.includeOccupants) { lotOccupancy.lotOccupancyOccupants = await getLotOccupancyOccupants( - lotOccupancy.lotOccupancyId!, + lotOccupancy.lotOccupancyId, database ) } diff --git a/database/getWorkOrders.ts b/database/getWorkOrders.ts index 64a1ca91..0ddd1cb6 100644 --- a/database/getWorkOrders.ts +++ b/database/getWorkOrders.ts @@ -106,7 +106,7 @@ async function addInclusions( ): Promise { if (options.includeComments ?? false) { workOrder.workOrderComments = await getWorkOrderComments( - workOrder.workOrderId!, + workOrder.workOrderId, database ) } diff --git a/database/moveFee.js b/database/moveFee.js index 5cfd66b4..8bba8862 100644 --- a/database/moveFee.js +++ b/database/moveFee.js @@ -56,7 +56,7 @@ export async function moveFeeUp(feeId) { } export async function moveFeeUpToTop(feeId) { const database = await acquireConnection(); - const currentFee = await getFee(feeId, database); + const currentFee = (await getFee(feeId, database)); if (currentFee.orderNumber > 0) { updateRecordOrderNumber('Fees', feeId, -1, database); database diff --git a/database/moveFee.ts b/database/moveFee.ts index dadec48a..d034ea92 100644 --- a/database/moveFee.ts +++ b/database/moveFee.ts @@ -1,3 +1,4 @@ +import { Fee } from '../types/recordTypes.js' import { getFee } from './getFee.js' import { acquireConnection } from './pool.js' import { updateRecordOrderNumber } from './updateRecordOrderNumber.js' @@ -100,7 +101,7 @@ export async function moveFeeUp(feeId: number): Promise { export async function moveFeeUpToTop(feeId: number | string): Promise { const database = await acquireConnection() - const currentFee = await getFee(feeId, database) + const currentFee = (await getFee(feeId, database)) as Fee if (currentFee.orderNumber! > 0) { updateRecordOrderNumber('Fees', feeId, -1, database) diff --git a/handlers/lotOccupancies-get/new.ts b/handlers/lotOccupancies-get/new.ts index 6a1c6400..535ab42a 100644 --- a/handlers/lotOccupancies-get/new.ts +++ b/handlers/lotOccupancies-get/new.ts @@ -21,7 +21,7 @@ export async function handler( ): Promise { const startDate = new Date() - const lotOccupancy: LotOccupancy = { + const lotOccupancy: Partial = { occupancyStartDate: dateToInteger(startDate), occupancyStartDateString: dateToString(startDate) } diff --git a/handlers/workOrders-get/new.ts b/handlers/workOrders-get/new.ts index c137acc6..19e351d8 100644 --- a/handlers/workOrders-get/new.ts +++ b/handlers/workOrders-get/new.ts @@ -10,7 +10,7 @@ export async function handler( ): Promise { const currentDate = new Date() - const workOrder: WorkOrder = { + const workOrder: Partial = { workOrderOpenDate: dateToInteger(currentDate), workOrderOpenDateString: dateToString(currentDate) } diff --git a/types/recordTypes.d.ts b/types/recordTypes.d.ts index 06ce5d25..2c164be5 100644 --- a/types/recordTypes.d.ts +++ b/types/recordTypes.d.ts @@ -187,12 +187,12 @@ export interface LotOccupancyComment extends Record { lotOccupancyComment?: string; } export interface LotOccupancyField extends OccupancyTypeField, Record { - lotOccupancyId?: number; - occupancyTypeFieldId?: number; + lotOccupancyId: number; + occupancyTypeFieldId: number; lotOccupancyFieldValue?: string; } export interface LotOccupancy extends Record { - lotOccupancyId?: number; + lotOccupancyId: number; occupancyTypeId?: number; occupancyType?: string; printEJS?: string; diff --git a/types/recordTypes.ts b/types/recordTypes.ts index f6e220e2..083e280b 100644 --- a/types/recordTypes.ts +++ b/types/recordTypes.ts @@ -245,13 +245,13 @@ export interface LotOccupancyComment extends Record { } export interface LotOccupancyField extends OccupancyTypeField, Record { - lotOccupancyId?: number - occupancyTypeFieldId?: number + lotOccupancyId: number + occupancyTypeFieldId: number lotOccupancyFieldValue?: string } export interface LotOccupancy extends Record { - lotOccupancyId?: number + lotOccupancyId: number occupancyTypeId?: number occupancyType?: string