Documentation Index
Fetch the complete documentation index at: https://mintlify.com/nelrondon/backend-proyecto-estructuras/llms.txt
Use this file to discover all available pages before exploring further.
POST /api/register creates a brand-new user record in the database. The request body is validated against the full Zod userSchema before any database work begins. If validation passes and no conflicts exist, the server hashes the password with bcrypt, inserts the row, signs a 7-day JWT, and writes it into an HTTP-only cookie — all in a single round-trip. The JSON response immediately gives you the new user’s profile so you can bootstrap your UI without a second request.
Endpoint
Request Body
The user’s full name. Must not contain any numeric characters (
0–9). Validated by the regex /[0-9]/ — if a digit is found the request is rejected with a 422.A valid email address (e.g.
john@example.com). Validated with Zod’s .email() rule. Must be unique across all registered users.A phone number matching the pattern
(\+?\d{1,3}[-. ]?)?\(?\d{3}\)?[-. ]?\d{3}[-. ]?\d{4}. Accepts formats such as +1-800-555-1234, (800) 555 1234, or 8005551234. Must be unique across all registered users.The user’s chosen username. Must be unique across all registered users.
The account password (plain text over HTTPS). The server hashes it with
bcrypt before storing — the raw password is never persisted.Uniqueness Constraint
Before inserting, the model runs:{ "error": "Username, email o teléfono ya registrados." }.
Example Request
Responses
200 — Success
Thetoken cookie is set in the response headers. The body contains the newly created user’s profile.
UUID assigned to the new user (generated with
crypto.randomUUID()).The user’s full name as provided in the request.
The username chosen during registration.
The user’s email address.
The user’s phone number.
ISO 8601 timestamp set to
CURRENT_TIMESTAMP at the moment of insertion.422 — Validation Error
Returned when any field fails Zod schema validation. The first validation message is extracted from the error array and returned directly.500 — Conflict or Server Error
Returned when the username, email, or phone is already registered, or when theINSERT statement fails for any other reason.