Skip to main content

Prerequisites

Before you start, make sure you have the following installed:

Docker

Docker and Docker Compose are required to run PostgreSQL 17 and the API in containers.

Node.js 22 LTS

The API targets Node.js 22. Install it from nodejs.org or via a version manager like nvm.

Get up and running

1

Clone the repository

Clone the project and move into the directory:
git clone <your-repo-url> restaurante-api
cd restaurante-api
2

Run the setup script

The setup script installs dependencies, copies the environment file, and starts the Docker containers for you.
npm run setup
Alternatively, if you want to start the containers directly without the interactive setup:
npm run dev
This runs docker compose up --build, which starts both the PostgreSQL 17 database and the NestJS API.
The first build may take a couple of minutes while Docker pulls the base images and installs npm packages inside the container.
3

Run database migrations and seed data

Once the containers are running, apply the Drizzle ORM migrations and load the initial seed data:
npm run db:migrate
npm run db:seed
Or reset, migrate, and seed everything in one command:
npm run db:fresh
4

Verify the API is running

Confirm the server is up by calling the login endpoint:
curl -s -X POST http://localhost:3000/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"nombre_usuario": "admin", "contrasena": "Admin123!"}'
A successful response looks like this:
{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "usuario": {
    "id": "usr_1234567890",
    "nombre": "Administrador",
    "nombre_usuario": "admin",
    "rol": "admin"
  }
}
If you see an access_token in the response, the API is fully operational.

Explore the API with Swagger UI

The interactive Swagger UI is available at:
http://localhost:3000/api
You can authenticate directly in Swagger using the Authorize button — paste your access_token and all subsequent requests will include the Bearer header automatically. The token is persisted in localStorage between page refreshes.

Useful commands

CommandWhat it does
npm run devStart all containers (PostgreSQL + API)
npm run downStop containers
npm run db:migrateRun pending Drizzle migrations
npm run db:seedLoad initial data
npm run db:freshReset + migrate + seed in one step
npm run docker:logsStream API logs from Docker
npm run docker:shellOpen a bash shell inside the API container

Build docs developers (and LLMs) love