refactor: clean up code formatting and improve readability in audit and email service files
This commit is contained in:
parent
47b23001ec
commit
ed129ee56d
|
|
@ -1,7 +1,10 @@
|
|||
import express from 'express'
|
||||
import rateLimit from 'express-rate-limit'
|
||||
import { body, validationResult } from 'express-validator'
|
||||
import { sendAuditRequestEmail, sendQuickcheckRequestEmail } from '../services/emailService.js'
|
||||
import {
|
||||
sendAuditRequestEmail,
|
||||
sendQuickcheckRequestEmail,
|
||||
} from '../services/emailService.js'
|
||||
|
||||
const router = express.Router()
|
||||
|
||||
|
|
@ -50,11 +53,14 @@ const validateQuickcheckRequest = [
|
|||
]
|
||||
|
||||
const validateRequest = (req, _res, next) => {
|
||||
const validators = req.body.formType === 'quickcheck'
|
||||
const validators =
|
||||
req.body.formType === 'quickcheck'
|
||||
? validateQuickcheckRequest
|
||||
: validateAuditRequest
|
||||
|
||||
Promise.all(validators.map((validator) => validator.run(req))).then(() => next())
|
||||
Promise.all(validators.map((validator) => validator.run(req))).then(() =>
|
||||
next(),
|
||||
)
|
||||
}
|
||||
|
||||
router.post('/', auditLimiter, validateRequest, async (req, res) => {
|
||||
|
|
@ -69,7 +75,14 @@ router.post('/', auditLimiter, validateRequest, async (req, res) => {
|
|||
})
|
||||
}
|
||||
|
||||
const { formType = 'audit', name, email, businessConfirmation, gdprConsent, website } = req.body
|
||||
const {
|
||||
formType = 'audit',
|
||||
name,
|
||||
email,
|
||||
businessConfirmation,
|
||||
gdprConsent,
|
||||
website,
|
||||
} = req.body
|
||||
|
||||
if (website) {
|
||||
console.warn('Honeypot triggered, discarding submission.')
|
||||
|
|
|
|||
|
|
@ -35,7 +35,9 @@ function getTransporter() {
|
|||
* when it is used in Subject or Reply-To.
|
||||
*/
|
||||
function singleLine(value) {
|
||||
return String(value).replace(/[\r\n]+/g, ' ').trim()
|
||||
return String(value)
|
||||
.replace(/[\r\n]+/g, ' ')
|
||||
.trim()
|
||||
}
|
||||
|
||||
/** Minimal HTML escaping - the payload is attacker-controlled by definition. */
|
||||
|
|
|
|||
|
|
@ -365,22 +365,22 @@ export interface TextConfig {
|
|||
problem: {
|
||||
title: string;
|
||||
intro: string;
|
||||
items: { text: string }[];
|
||||
items: { text: string; }[];
|
||||
outro: string;
|
||||
};
|
||||
deliverable: {
|
||||
title: string;
|
||||
intro: string;
|
||||
items: { title: string; text: string }[];
|
||||
items: { title: string; text: string; }[];
|
||||
};
|
||||
process: {
|
||||
title: string;
|
||||
steps: { title: string; text: string }[];
|
||||
steps: { title: string; text: string; }[];
|
||||
};
|
||||
limits: {
|
||||
title: string;
|
||||
intro: string;
|
||||
items: { text: string }[];
|
||||
items: { text: string; }[];
|
||||
outro: string;
|
||||
};
|
||||
form: {
|
||||
|
|
|
|||
|
|
@ -258,7 +258,6 @@
|
|||
&__features {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue