This guide walks you through getting a local instance of the Estructuras Backend API running from scratch and executing your first authenticated real estate listing request. You will clone the repository, configure the required environment variables, start the server, register a user, log in, and query both the user profile and the property catalog — all in a few minutes.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.
The Estructuras API issues authentication tokens as HTTP-only cookies. In a browser you must always send requests with
credentials: 'include' (Fetch API) or withCredentials: true (Axios) so the cookie is attached automatically. For curl, use -c cookies.txt -b cookies.txt to persist and replay the cookie across commands. Examples for both are provided in each step below.Prerequisites
- Node.js 18 or later
- pnpm 10 or later (
npm install -g pnpm) - A Turso account with access to the
estructuradb-nelrondondatabase (or your own Turso database — see Configuration)
Clone the repository and install dependencies
Clone the project from GitHub and install all dependencies with pnpm. Because the project ships a After installation your
packageManager field pinned to pnpm@10.12.1, npm and yarn will warn you to switch.node_modules will contain Express v5, @libsql/client, jsonwebtoken, bcrypt, zod, and the rest of the runtime dependencies.Create your .env file
The server will not start without a valid
.env file at the project root. Create one based on the template below:| Variable | Required | Description |
|---|---|---|
PORT | No (default: 3000) | TCP port the HTTP server will bind to |
SECRET_KEY | Yes | Secret used to sign and verify JWTs — must be a strong random string in production |
DB_TOKEN | Yes | Turso authentication token for libsql://estructuradb-nelrondon.aws-us-east-1.turso.io |
SALT_ROUNDS | No (default: 10) | bcrypt cost factor for password hashing |
Start the server
The You should see the following output in your terminal:You can verify the server is alive by hitting the root endpoint:
start script launches the server using Node.js built-in --watch mode, which restarts the process automatically whenever a source file changes — no nodemon required.Register a new user
Send a Successful response (200):
POST request to /api/register with the five required user fields. On success the server creates the account, signs a 7-day JWT, and sets it as an HTTP-only token cookie.Log in
If you already have an account — or want to start a new session — send credentials to Successful response (200):The
POST /api/login. Only username and password are required. The server validates credentials, signs a fresh JWT, and writes the token cookie.-c cookies.txt flag tells curl to save the Set-Cookie header to cookies.txt. The -b cookies.txt flag tells curl to send cookies from that file on future requests. You must include both flags on every subsequent authenticated request.Fetch your profile
With the session cookie in hand, call Successful response (200):
GET /api/ to retrieve the authenticated user’s full profile. This endpoint requires a valid token cookie — it will return 401 Unauthorized if the cookie is missing or the JWT has expired.Next Steps
Now that your server is running and you have made your first authenticated requests, explore the rest of the documentation:- Configuration — Learn about every environment variable, how CORS works, and how to obtain your Turso auth token.
- API Reference — Full endpoint documentation with request/response schemas, error codes, and field-level descriptions.