Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Distribuidos-Org/ms-alumnos/llms.txt
Use this file to discover all available pages before exploring further.
ms-alumnos validates every environment variable at process startup using a Joi schema defined in src/config/envs.ts. If any required variable is missing, has the wrong type, or cannot be parsed, the service throws immediately with a descriptive error message and refuses to start — preventing silent misconfiguration from reaching production. This fail-fast behaviour means you will always know exactly which variables are problematic before the first request is ever processed.
Environment file
Copy.env.example to .env and fill in the values for your environment:
.env.example are:
Variable reference
Validated and exported by
envs.ts but not used to open an HTTP listener — ms-alumnos is a pure NATS microservice and has no HTTP server. The variable must be present and numeric for startup validation to pass.Default (from example): 3002A comma-separated list of one or more NATS server URLs. At startup, the value is split on
, and passed as an array to the NestJS NATS transport, which will attempt to connect to each server in order and maintain a resilient connection.Example: nats://localhost:4222,nats://localhost:4223For a single-server local setup you can simplify this to:The PostgreSQL username the service uses to authenticate with the database. Must match the
POSTGRES_USER value configured in your PostgreSQL instance (or the Docker Compose service).Default (from example): postgresThe password for the PostgreSQL user specified in
DB_USER. Must match POSTGRES_PASSWORD in your PostgreSQL instance.Default (from example): postgresThe name of the PostgreSQL database that
ms-alumnos will connect to and manage. TypeORM will use this database to create and migrate the student records schema.Default (from example): ms-alumnos-dbThe hostname or IP address of the PostgreSQL server. When running the database inside Docker Compose and the microservice on the host machine (e.g. with
yarn start:dev), this should be localhost.Default (from example): localhostThe host-side TCP port on which PostgreSQL is reachable. This is the host-mapped port, not the internal container port (which is always
5432). The Docker Compose configuration maps ${DB_PORT} on the host to 5432 inside the container.Default (from example): 5435Validation
The Joi schema insrc/config/envs.ts enforces the following rules at startup:
NATS_SERVERS is pre-processed by splitting the raw string value on commas:
.env file, and the config module converts it to a string[] that NestJS hands directly to the NATS transport.
Validation runs with abortEarly: false, so all invalid or missing fields are reported in a single error at startup rather than one at a time. If validation fails, the process exits with an error like:
Docker Compose defaults
The includeddocker-compose.yml provisions a postgres:15 container and reads its configuration directly from the same .env file via Docker Compose variable interpolation:
- The
POSTGRES_USER,POSTGRES_DB, andPOSTGRES_PASSWORDenvironment variables inside the container are automatically set to the same values you configured for the microservice — no duplication needed. - The host port (
DB_PORT, default5435) is mapped to the container’s internal PostgreSQL port (5432). This avoids conflicts if you already have a PostgreSQL instance running on the standard port5432on your machine. - Database files are stored in the named Docker volume
db_data, so your data persists acrossdocker compose downanddocker compose upcycles.
When running the microservice with
yarn start:dev alongside Docker Compose, set DB_HOST=localhost so that TypeORM connects to the database through the host-mapped port. If you run both the microservice and the database inside the same Docker network in the future, update DB_HOST to the service name (db) instead.