Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/15aozzz/Lab-Nova-Salud/llms.txt

Use this file to discover all available pages before exploring further.

The Botica Nova Salud API is a RESTful HTTP service built with Node.js and Express. It powers the pharmacy sales management frontend and exposes resources for authentication, sales, products, clients, receipts, dashboard metrics, and user management. Every data operation delegates to a MySQL Stored Procedure — the backend does not execute raw SQL queries directly. All request and response bodies use JSON. Set Content-Type: application/json on every request that sends a body.

Base URL

http://localhost:3000/api
The port is configurable via the PORT environment variable in backend/.env. When PORT is not set, the server defaults to 3000.
PORT=3000

Health check

Use the health endpoint to verify the server is running before making other requests.
curl http://localhost:3000/api/health
Response
{
  "status": "ok",
  "message": "Backend Nova Salud funcionando correctamente"
}
The health endpoint does not require authentication.

Endpoint groups

All endpoints are protected with JWT Bearer token authentication except POST /api/auth/login. See Authentication for details on obtaining and using tokens.

Authentication

Login and obtain a JWT token. Required before calling any other endpoint.

Comprobantes

Retrieve receipt types (BOLETA, FACTURA) and series/correlative numbers for new sales documents.

Clientes

List, search, create, and update client records by document number.

Productos

Browse, search, create, and update products with their pricing tiers.

Ventas

Register a complete sale transaction and retrieve the detail of an existing sale by ID.

Dashboard

Fetch aggregated KPIs, weekly sales charts, and low-stock alerts for the dashboard view.

Usuarios

List, search, create, update, and delete system user accounts and employee records.

Available endpoints

The table below lists every endpoint, the Stored Procedure it invokes, and a short description.
MethodEndpointStored procedureDescription
POST/api/auth/loginsp_loginAuthenticate and receive a JWT
GET/api/comprobantessp_listar_comprobantesList vouchers with optional date/type/search filters
GET/api/comprobantes/tipossp_get_tipos_comprobanteList receipt types (BOLETA, FACTURA, …)
GET/api/comprobantes/serie/:id_tiposp_get_serie_correlativoSeries and next correlative number
GET/api/clientessp_get_todos_clientesList all clients with optional search filter
GET/api/clientes/buscar?doc=sp_buscar_clienteSearch client by document number
POST/api/clientessp_crear_clienteCreate a new client
PUT/api/clientes/:idsp_actualizar_clienteUpdate a client’s document or name
GET/api/productossp_get_todos_productosFull product catalog with pricing tiers
GET/api/productos/buscar?q=sp_buscar_productosSearch products with prices
GET/api/productos/:id/preciossp_get_precios_productoAvailable price tiers for a product
POST/api/productossp_crear_producto + sp_agregar_precio_productoCreate a new product with pricing
PUT/api/productos/:idsp_actualizar_producto_completoUpdate a product and its pricing tiers
POST/api/ventas/registrarsp_registrar_ventaRegister a complete sale
GET/api/ventas/:idsp_get_venta_detalleRetrieve sale detail by ID
GET/api/dashboard/resumenMultiple SPsKPIs, weekly chart, alerts, recent vouchers
GET/api/usuariossp_get_todos_usuariosList all users with optional search filter
GET/api/usuarios/buscar?username=sp_buscar_usuarioSearch user by username
GET/api/usuarios/empleadossp_get_empleadosList employees available for user assignment
POST/api/usuariossp_crear_usuarioCreate a new user account
PUT/api/usuarios/:idsp_actualizar_usuarioUpdate user credentials or employee link
DELETE/api/usuarios/:idsp_eliminar_usuarioDelete a user account
GET/api/healthHealth check — no auth required

Request format

  • Content-Type: application/json for all requests with a body.
  • Authorization: Authorization: Bearer <token> for all protected endpoints.
  • Encoding: UTF-8.

Response format

All responses return JSON. Successful responses use 2xx status codes. Errors return an object with an error string field and an appropriate 4xx or 5xx status code.
{ "error": "Ocurrió un error en el servidor" }

Stored procedures

The backend uses MySQL Stored Procedures for all data operations. This means:
  • No raw SQL runs in the route handlers.
  • Business logic such as stock validation and sale registration lives inside the database (sp_registrar_venta, triggers, etc.).
  • The MySQL pool is configured with multipleStatements: true to handle SPs that return multiple result sets.

Build docs developers (and LLMs) love