fix: fuck

This commit is contained in:
orion 2023-12-12 19:37:28 -06:00
parent da860c8f39
commit 3d9aa86ffe
Signed by: orion
GPG Key ID: 6D4165AE4C928719

View File

@ -1,35 +1,4 @@
import { checkSyntax, checkMX, checkSMTP } from 'qed-mail' import { checkEmail } from 'qed-mail'
const DEFAULT_RESULT = {
reachable: false,
syntax: { valid: false },
mx: { valid: false },
smtp: { valid: false },
};
/** @type {(_: string) => Promise<import('qed-mail/src/types.js').Result>} */
async function checkEmail(email) {
const result = { email, ...DEFAULT_RESULT };
const syntax = checkSyntax(email);
if (!syntax.valid) {
return { ...result, syntax };
}
const mx = await checkMX(syntax.domain || '');
if (!mx.valid || !mx.mxRecords) {
return { ...result, syntax, mx };
}
const records = mx.mxRecords.sort((a, b) => a.priority - b.priority);
const smtp = await checkSMTP(email, records[0].exchange, 500);
if (!smtp.valid) {
return { ...result, syntax, mx, smtp };
}
return { ...result, reachable: true, syntax, mx, smtp };
}
/** @type {(_: string) => () => Promise<import('qed-mail/src/types.js').Result>} */ /** @type {(_: string) => () => Promise<import('qed-mail/src/types.js').Result>} */
export const checkEmailImpl = s => () => checkEmail(s) export const checkEmailImpl = s => () => checkEmail(s)