MCPcopy Create free account
hub / github.com/boringstack-xyz/boringstack / checkEmailProvider

Function checkEmailProvider

apps/api/src/config/env/validate.ts:463–501  ·  view source on GitHub ↗
(env: Env)

Source from the content-addressed store, hash-verified

461};
462
463const checkEmailProvider = (env: Env): string[] => {
464 if (env.NODE_ENV !== "production") {
465 return [];
466 }
467
468 // Cloudflare Email Service needs an account-scoped endpoint AND a token.
469 if (env.EMAIL_PROVIDER === "cloudflare") {
470 if (
471 env.CLOUDFLARE_ACCOUNT_ID === "" ||
472 env.CLOUDFLARE_EMAIL_API_TOKEN === ""
473 ) {
474 return [
475 "Email provider 'cloudflare' requires both CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_EMAIL_API_TOKEN",
476 ];
477 }
478
479 return checkEmailFromDomain(env);
480 }
481
482 // SMTP just needs a host; auth is optional (Mailpit accepts any).
483 if (env.EMAIL_PROVIDER === "smtp") {
484 return env.SMTP_HOST === ""
485 ? ["Email provider 'smtp' requires SMTP_HOST"]
486 : checkEmailFromDomain(env);
487 }
488
489 const keyByProvider: Record<"resend" | "sendgrid", string> = {
490 resend: env.RESEND_API_KEY,
491 sendgrid: env.SENDGRID_API_KEY,
492 };
493
494 if (keyByProvider[env.EMAIL_PROVIDER] === "") {
495 return [
496 `Email provider '${env.EMAIL_PROVIDER}' selected but its API key is missing`,
497 ];
498 }
499
500 return checkEmailFromDomain(env);
501};
502
503const checkEmailFromDomain = (env: Env): string[] => {
504 if (!isPlaceholderFromAddress(env.EMAIL_FROM)) {

Callers 1

checkInvariantsFunction · 0.85

Calls 1

checkEmailFromDomainFunction · 0.85

Tested by

no test coverage detected