add guild sql, move things around for req body
All checks were successful
Code quality checks / biome (push) Successful in 9s
All checks were successful
Code quality checks / biome (push) Successful in 9s
This commit is contained in:
parent
33a602cdd0
commit
ca0410f7fb
30 changed files with 332 additions and 183 deletions
|
@ -1,48 +0,0 @@
|
|||
import { isValidEmail } from "./email";
|
||||
import { isValidHostname, isValidPort } from "./general";
|
||||
|
||||
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 };
|
Loading…
Add table
Add a link
Reference in a new issue