chore: lint entire codebase including db packages

This commit is contained in:
Alessio Gravili
2024-09-03 11:19:19 -04:00
parent 7a3507d597
commit 7fd736ea5b
53 changed files with 536 additions and 243 deletions

View File

@@ -46,8 +46,12 @@ export const sanitizeQueryValue = ({
// Cast incoming values as proper searchable types
if (field.type === 'checkbox' && typeof val === 'string') {
if (val.toLowerCase() === 'true') formattedValue = true
if (val.toLowerCase() === 'false') formattedValue = false
if (val.toLowerCase() === 'true') {
formattedValue = true
}
if (val.toLowerCase() === 'false') {
formattedValue = false
}
}
if (['all', 'in', 'not_in'].includes(operator) && typeof formattedValue === 'string') {
@@ -95,11 +99,14 @@ export const sanitizeQueryValue = ({
if (operator === 'in' && Array.isArray(formattedValue)) {
formattedValue = formattedValue.reduce((formattedValues, inVal) => {
const newValues = [inVal]
if (mongoose.Types.ObjectId.isValid(inVal))
if (mongoose.Types.ObjectId.isValid(inVal)) {
newValues.push(new mongoose.Types.ObjectId(inVal))
}
const parsedNumber = parseFloat(inVal)
if (!Number.isNaN(parsedNumber)) newValues.push(parsedNumber)
if (!Number.isNaN(parsedNumber)) {
newValues.push(parsedNumber)
}
return [...formattedValues, ...newValues]
}, [])
@@ -129,8 +136,12 @@ export const sanitizeQueryValue = ({
$geometry: { type: 'Point', coordinates: [parseFloat(lng), parseFloat(lat)] },
}
if (maxDistance) formattedValue.$maxDistance = parseFloat(maxDistance)
if (minDistance) formattedValue.$minDistance = parseFloat(minDistance)
if (maxDistance) {
formattedValue.$maxDistance = parseFloat(maxDistance)
}
if (minDistance) {
formattedValue.$minDistance = parseFloat(minDistance)
}
}
}