Documentation Index
Fetch the complete documentation index at: https://mintlify.com/andreguti9190/Sistema-de-gestion-de-ventas--Nodejs/llms.txt
Use this file to discover all available pages before exploring further.
Configuration Guide
The Sales Management System API uses a centralized configuration file for all environment-specific settings.Configuration File
The main configuration is located atsrc/config.js:
Configuration Parameters
Server Configuration
PORT
The port on which the Express server listens.- Type:
number - Default:
3000 - Example:
PORT: 8080
If port 3000 is already in use, change this to an available port like 3001 or 8080.
Database Configuration
HOST_DATABASE
MySQL server hostname or IP address.- Type:
string - Default:
"localhost" - Examples:
- Local:
"localhost"or"127.0.0.1" - Remote:
"db.example.com"or"192.168.1.100"
- Local:
PORT_DATABASE
MySQL server port.- Type:
number - Default:
3306 - Example:
PORT_DATABASE: 3307(for non-standard MySQL port)
DATABASE_NAME
Name of the MySQL database.- Type:
string - Default:
"erpDB" - Example:
DATABASE_NAME: "sales_system"
USER_DATABASE
MySQL username for authentication.- Type:
string - Default:
"root" - Example:
USER_DATABASE: "sales_api_user"
PASSWORD_DATABASE
MySQL password for authentication.- Type:
string - Default:
"admin" - Example:
PASSWORD_DATABASE: "my_secure_password_123"
Environment Variables (Recommended)
For production and team environments, use environment variables instead of hardcoded values.Setup
- Install dotenv (optional):
- Create
.envfile:
- Update
config.js:
- Add
.envto.gitignore:
System Environment Variables
Alternatively, set environment variables at the system level: Linux/macOS:Connection Pool Configuration
The database connection pool is configured insrc/model/pool.js:
Advanced Pool Options
You can extend the pool configuration with additional options:Pool Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
connectionLimit | number | 10 | Maximum connections in pool |
queueLimit | number | 0 | Max queued connection requests (0 = unlimited) |
waitForConnections | boolean | true | Wait for connection when pool is full |
connectTimeout | number | 10000 | Milliseconds before connection timeout |
acquireTimeout | number | 10000 | Milliseconds before acquire timeout |
timezone | string | ’local’ | Timezone for MySQL TIMESTAMP columns |
charset | string | ’UTF8_GENERAL_CI’ | Character set for connection |
Environment-Specific Configurations
Development
Testing
Production
Configuration Validation
Add validation to ensure all required config values are present:Troubleshooting
Cannot connect to MySQL
Cannot connect to MySQL
Check:
- MySQL service is running:
sudo systemctl status mysql - Host and port are correct
- Firewall allows connection on port 3306
- MySQL is listening on the correct interface:
Access denied for user
Access denied for user
Check:
- Username and password are correct
- User has permissions on the database:
- User exists:
Unknown database error
Unknown database error
Solution:
Create the database:Or check the database name:
Port already in use
Port already in use
Solutions:
- Change PORT in config.js to a different value (e.g., 3001)
- Find and kill the process using the port:
Security Best Practices
Create Dedicated Database User
Don’t use the
root user. Create a user with minimal required privileges:Use Strong Passwords
Generate secure passwords with at least 16 characters including uppercase, lowercase, numbers, and symbols.
Next Steps
Installation
Complete installation guide
Architecture
Learn how configuration is used
Database Schema
Understand the database structure
Error Handling
Handle connection errors