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 express from 'express'
|
||||||
import rateLimit from 'express-rate-limit'
|
import rateLimit from 'express-rate-limit'
|
||||||
import { body, validationResult } from 'express-validator'
|
import { body, validationResult } from 'express-validator'
|
||||||
import { sendAuditRequestEmail, sendQuickcheckRequestEmail } from '../services/emailService.js'
|
import {
|
||||||
|
sendAuditRequestEmail,
|
||||||
|
sendQuickcheckRequestEmail,
|
||||||
|
} from '../services/emailService.js'
|
||||||
|
|
||||||
const router = express.Router()
|
const router = express.Router()
|
||||||
|
|
||||||
|
|
@ -50,11 +53,14 @@ const validateQuickcheckRequest = [
|
||||||
]
|
]
|
||||||
|
|
||||||
const validateRequest = (req, _res, next) => {
|
const validateRequest = (req, _res, next) => {
|
||||||
const validators = req.body.formType === 'quickcheck'
|
const validators =
|
||||||
? validateQuickcheckRequest
|
req.body.formType === 'quickcheck'
|
||||||
: validateAuditRequest
|
? 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) => {
|
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) {
|
if (website) {
|
||||||
console.warn('Honeypot triggered, discarding submission.')
|
console.warn('Honeypot triggered, discarding submission.')
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,9 @@ function getTransporter() {
|
||||||
* when it is used in Subject or Reply-To.
|
* when it is used in Subject or Reply-To.
|
||||||
*/
|
*/
|
||||||
function singleLine(value) {
|
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. */
|
/** Minimal HTML escaping - the payload is attacker-controlled by definition. */
|
||||||
|
|
|
||||||
|
|
@ -365,22 +365,22 @@ export interface TextConfig {
|
||||||
problem: {
|
problem: {
|
||||||
title: string;
|
title: string;
|
||||||
intro: string;
|
intro: string;
|
||||||
items: { text: string }[];
|
items: { text: string; }[];
|
||||||
outro: string;
|
outro: string;
|
||||||
};
|
};
|
||||||
deliverable: {
|
deliverable: {
|
||||||
title: string;
|
title: string;
|
||||||
intro: string;
|
intro: string;
|
||||||
items: { title: string; text: string }[];
|
items: { title: string; text: string; }[];
|
||||||
};
|
};
|
||||||
process: {
|
process: {
|
||||||
title: string;
|
title: string;
|
||||||
steps: { title: string; text: string }[];
|
steps: { title: string; text: string; }[];
|
||||||
};
|
};
|
||||||
limits: {
|
limits: {
|
||||||
title: string;
|
title: string;
|
||||||
intro: string;
|
intro: string;
|
||||||
items: { text: string }[];
|
items: { text: string; }[];
|
||||||
outro: string;
|
outro: string;
|
||||||
};
|
};
|
||||||
form: {
|
form: {
|
||||||
|
|
|
||||||
|
|
@ -258,7 +258,6 @@
|
||||||
&__features {
|
&__features {
|
||||||
grid-template-columns: repeat(3, 1fr);
|
grid-template-columns: repeat(3, 1fr);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (prefers-reduced-motion: reduce) {
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue