add guild sql, move things around for req body
All checks were successful
Code quality checks / biome (push) Successful in 9s

This commit is contained in:
creations 2025-06-18 17:45:30 -04:00
parent 33a602cdd0
commit ca0410f7fb
Signed by: creations
GPG key ID: 8F553AA4320FC711
30 changed files with 332 additions and 183 deletions

View file

@ -0,0 +1,48 @@
import { isValidHostname, isValidPort } from "../general";
import { isValidEmail } from "./email";
import type { MailerConfig } from "#types/config";
import type { simpleConfigValidation } from "#types/lib";
function validateMailerConfig(config: MailerConfig): simpleConfigValidation {
const errors: string[] = [];
const isValidSMTPAddress = isValidHostname(config.address);
if (!isValidSMTPAddress) {
errors.push(`Invalid SMTP address: ${config.address}`);
}
if (!isValidPort(config.port)) {
errors.push(
`Invalid SMTP port: ${config.port}. Port must be between 1 and 65535`,
);
}
if (!isValidEmail(config.from)) {
errors.push(`Invalid from email address: ${config.from}`);
}
if (!isValidEmail(config.username)) {
errors.push(`Invalid username email address: ${config.username}`);
}
if (!config.password || config.password.trim().length === 0) {
errors.push("SMTP password is required");
}
if (config.port === 465 && !config.secure) {
errors.push("Port 465 requires SMTP_SECURE=true");
}
if (config.port === 587 && config.secure) {
errors.push("Port 587 typically uses SMTP_SECURE=false with STARTTLS");
}
return {
isValid: errors.length === 0,
errors,
};
}
export { isValidPort, isValidEmail, validateMailerConfig };