Documentation Index
Fetch the complete documentation index at: https://mintlify.com/JuanSebasSV/healtyhelp/llms.txt
Use this file to discover all available pages before exploring further.
Overview
HealtyHelp uses two email-driven flows to keep accounts secure: email verification after registration and password reset for forgotten credentials. Both flows use the Resend email API and a shared HTML template (emailBase) to send branded emails.
Email Service Setup
Emails are sent through the Resend API using a thinenviarEmail wrapper:
Required environment variables
| Variable | Description | Example |
|---|---|---|
RESEND_API_KEY | API key from your Resend dashboard | re_xxxxxxxxxxxx |
EMAIL_FROM | Sender address shown in the email From field | Healthy Help <no-reply@healthyhelpoficial.com> |
Email template (emailBase)
All transactional emails share the same dark-themed HTML template produced by the emailBase helper. It accepts:
| Option | Description |
|---|---|
titulo | Bold heading inside the email card |
subtitulo | Smaller subtitle below the heading |
contenido | Main HTML body content |
footerTexto | Small disclaimer text in the footer |
Email Verification Flow
After registration, new accounts are unverified (isVerified: false). The user cannot log in until they submit the correct code.
Register an account
Submit a Success response (
POST /api/auth/register request. The server generates a 6-digit numeric code using Math.floor(100000 + Math.random() * 900000), hashes it with SHA-256, stores the hash and an expiry 15 minutes in the future, then sends the plaintext code to the user’s email.201):Check your inbox
The user receives a branded HealtyHelp email with the subject ”🔐 Verifica tu cuenta — Healthy Help”. Inside the email, each of the 6 digits is rendered in its own styled box. The code expires in 15 minutes.
Submit the verification code
verificationExpire > now.Success response (200):Code behaviour summary
| Detail | Value |
|---|---|
| Format | 6-digit numeric string (100000–999999) |
| Storage | SHA-256 hash of the plaintext code |
| Expiry | 15 minutes from generation |
| Re-registration | If the email exists but is unverified, a new code is sent automatically |
Forgot Password Flow
Request a password reset
200 success response (to avoid revealing whether an email exists in the system). If the email matches a verified account, a 32-byte random token is generated, hashed with SHA-256, and stored alongside a 30-minute expiry. The plaintext token is emailed as part of a reset link.Google-only accounts (no password set) cannot use the forgot-password flow. They are directed to sign in with Google instead.
Check your inbox
The user receives an email with the subject ”🔐 Recupera tu contraseña — Healthy Help” containing a styled button and a fallback plaintext link:The link expires in 30 minutes.
Submit the new password
The frontend extracts the token from the URL and calls:The server hashes the URL token, looks up the user, validates that
resetPasswordExpire > now, and applies the password rules. On success:- The new password is saved (bcrypt, 12 rounds).
resetPasswordTokenandresetPasswordExpireare cleared.loginAttemptsandlockUntilare reset (lifts any existing lockout).- A fresh JWT is returned.
200):Reset token details
| Detail | Value |
|---|---|
| Generation | crypto.randomBytes(32).toString('hex') |
| Storage | SHA-256 hash of the plaintext token |
| Expiry | 30 minutes from generation |
| Error message | "Token inválido o expirado. Solicita un nuevo enlace." |
Profile Completion Requirement
After verifying their email, users who did not supply all health metrics at registration must complete their profile before they can fully use the platform. A user’s profile is considered complete (profileComplete: true) when all of the following are valid:
| Field | Constraint |
|---|---|
birthDate | User must be at least 18 years old (and no older than 120) |
weight | Between 40 kg and 300 kg |
height | Between 50 cm and 210 cm |
User logs in for the first time
The
profileComplete field in the user object is false. The frontend detects this and redirects the user to the profile completion screen.User submits their metrics
The
POST /api/auth/complete-profile endpoint validates the fields and, on success, sets profileComplete: true on the user document.Weight and height can also be provided at registration time. If valid values are supplied then,
profileComplete is set to true immediately after email verification — no extra step is needed.