The Audit Log API exposes theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/FloresJesus/SS_RESTAURANT/llms.txt
Use this file to discover all available pages before exploring further.
auditoria table, which records every significant action performed in the system. Entries are written automatically by the logAudit utility function (utils/auditLogger.js) at the point of the originating operation — no separate step is required. Each entry captures who performed the action (usuario_id), what they did (accion), which table was affected (tabla), which record (registro_id), a plain-text description (detalle), and the request IP address (direccion_ip). This provides a complete, tamper-evident trail for compliance, debugging, and operational review. All read and write access to the audit log is restricted to the admin role.
Automatic logging
ThelogAudit function is called throughout the codebase whenever a state-changing operation completes:
| Trigger | accion | tabla |
|---|---|---|
| User logs in | LOGIN | usuarios |
| New order created | CREAR | pedidos |
| Order status updated | ACTUALIZAR | pedidos |
| Order detail line added | CREAR | detalle_pedido |
| Payment processed | CREAR | pagos |
| Ticket generated | CREAR | tickets |
| Invoice generated | CREAR | facturas |
| Report generated | GENERAR | reportes |
| Report deleted | ELIMINAR | reportes |
| User account created | CREAR | usuarios |
| User account updated | ACTUALIZAR | usuarios |
| User account deleted | ELIMINAR | usuarios |
| Settings updated | ACTUALIZAR | configuracion |
Endpoints
| Method | Path | Auth | Description |
|---|---|---|---|
GET | /api/audit | admin | List audit log entries, with optional filters |
POST | /api/audit | admin | Manually record an audit entry |
GET /api/audit
Returns audit log entries joined with theusuario table to include the actor’s name and email. Without query parameters the full log is returned in descending timestamp order. Combine any of the filter parameters to narrow the results.
Query parameters
Filter by action type:
LOGIN, CREAR, ACTUALIZAR, ELIMINAR, or GENERAR.Filter by the name of the affected database table (e.g.,
pedidos, pagos, reportes).Filter entries by the ID of the user who performed the action.
ISO 8601 datetime lower bound for
creado_en (inclusive). Example: 2025-01-01T00:00:00.ISO 8601 datetime upper bound for
creado_en (inclusive). Example: 2025-01-31T23:59:59.Audit entry primary key.
ID of the user who performed the action.
First name of the acting user (joined from
usuario).Email of the acting user (joined from
usuario).Action type: one of
LOGIN, CREAR, ACTUALIZAR, ELIMINAR, or GENERAR.Name of the database table that was affected (e.g.,
pedidos, pagos, usuarios, reportes, detalle_pedido).Primary key of the affected record. May be
null for actions that do not map to a single row (e.g., settings updates).Human-readable description of the action, e.g.,
"Pago 15 para pedido 42 - efectivo Bs.120.5".IP address from which the request originated, as captured by
req.ip.ISO 8601 timestamp when the entry was recorded.
POST /api/audit
Manually inserts an audit entry. Intended for administrative tools or integration scripts that perform actions outside the standard API flow and still need to be recorded in the trail.Request body
Action type. Recommended values:
LOGIN, CREAR, ACTUALIZAR, ELIMINAR, GENERAR. Free-form strings are accepted but using the standard vocabulary keeps the log filterable.Name of the database table or resource being acted upon.
Primary key of the affected record, if applicable.
Plain-text description of what was done.
201 Created:
Error responses
| Status | Condition |
|---|---|
400 | accion or tabla not provided |
500 | Database or internal error |
Sample audit entry
The
logAudit utility is designed to be non-blocking — if the audit insert fails (e.g., due to a transient database error), it logs the error to console.error but does not throw, so the originating operation is not rolled back. Audit entries are best-effort; they should not be relied upon as the sole source of financial truth.