Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions api/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,13 @@ PORT=3001
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/aoweb
TOKEN_AUTH=changeme
CORS_ORIGIN=http://localhost:3000

# Site configuration
SITE_URL=http://localhost:3000

# Amazon SES (Password Reset emails)
SES_REGION=us-east-1
SES_ACCESS_KEY_ID=
SES_SECRET_ACCESS_KEY=
SES_FROM_EMAIL=noreply@aoweb.online
SES_FROM_NAME="AOWeb"
10 changes: 8 additions & 2 deletions api/src/lib/email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ type PasswordResetEmailInput = {
let sesClient: SESv2Client | null = null;

function getSesClient(): SESv2Client {
if (!config.sesRegion || !config.sesAccessKeyId || !config.sesSecretAccessKey || !config.sesFromEmail) {
throw new Error("Amazon SES no esta configurado");
const missing: string[] = [];
if (!config.sesRegion) missing.push("SES_REGION");
if (!config.sesAccessKeyId) missing.push("SES_ACCESS_KEY_ID");
if (!config.sesSecretAccessKey) missing.push("SES_SECRET_ACCESS_KEY");
if (!config.sesFromEmail) missing.push("SES_FROM_EMAIL");

if (missing.length > 0) {
throw new Error(`Amazon SES no esta configurado. Faltan variables: ${missing.join(", ")}`);
}

if (!sesClient) {
Expand Down