Overview
The Siigo Corprecam Scraper uses environment variables for configuration. All configuration is loaded from a.env file in the project root using the dotenv package.
Configuration File Location
The application loads configuration from:Environment Variables Reference
All environment variables are defined inconfig.ts (config.ts:5-15). Below is a complete reference:
Server Configuration
PORT
- Description: The port number on which the Express server will listen
- Type: Number
- Default:
3000 - Required: No
- Example:
PORT=3000
If not specified, the server will default to port 3000. Ensure this port is available and not blocked by your firewall.
Ngrok Configuration
NGROK_AUTHTOKEN
- Description: Authentication token for ngrok to create secure tunnels
- Type: String
- Default: None
- Required: Yes
- Example:
NGROK_AUTHTOKEN=2abcDEF123456_xyz789ABC
- Expose the local Express server to the internet
- Provide a public URL for webhook callbacks from the Corprecam system
- Automatically register the tunnel URL via the
setNgrok()API call (server.ts:51)
Siigo Corprecam Credentials
USER_SIIGO_CORPRECAM
- Description: Username for authenticating with the Siigo Corprecam system
- Type: String
- Default: Empty string
- Required: Yes
- Example:
[email protected]
PASSWORD_SIIGO_CORPRECAM
- Description: Password for authenticating with the Siigo Corprecam system
- Type: String
- Default: Empty string
- Required: Yes
- Example:
PASSWORD_SIIGO_CORPRECAM=your_secure_password
Database Configuration
The application uses MySQL2 for database connectivity (package.json:25). Configure the following variables to connect to your MySQL database:DB_HOST
- Description: MySQL server hostname or IP address
- Type: String
- Default: None
- Required: Yes
- Example:
DB_HOST=localhostorDB_HOST=192.168.1.100
DB_USER
- Description: MySQL database username
- Type: String
- Default: None
- Required: Yes
- Example:
DB_USER=corprecam_user
DB_PASSWORD
- Description: MySQL database password
- Type: String
- Default: None
- Required: Yes
- Example:
DB_PASSWORD=secure_db_password
DB_DATABASE
- Description: MySQL database name to connect to
- Type: String
- Default: None
- Required: Yes
- Example:
DB_DATABASE=corprecam_db
DB_PORT
- Description: MySQL server port number
- Type: Number
- Default: None (typically 3306)
- Required: Yes
- Example:
DB_PORT=3306
The standard MySQL port is 3306. Only change this if your MySQL server is configured to use a different port.
Complete .env Example
Here’s a complete example.env file with all required variables:
Configuration Loading
The configuration is loaded inconfig.ts using the following pattern:
Environment-Specific Configuration
For different environments (development, staging, production), you can create separate environment files:Security Best Practices
1. Use Strong Credentials
- Use complex passwords with a mix of uppercase, lowercase, numbers, and special characters
- Never use default or easily guessable passwords
- Rotate credentials regularly
2. Restrict File Permissions
On Unix-based systems, restrict access to your.env file:
3. Add .env to .gitignore
Ensure your.gitignore includes:
4. Use Environment Variable Validation
Consider adding validation to ensure all required variables are set before starting the application:Troubleshooting
Configuration Not Loading
If your environment variables aren’t being loaded:- Ensure the
.envfile is in the project root directory - Check for syntax errors (no spaces around
=) - Verify the file is named exactly
.env(not.env.txt) - Restart the application after making changes
Database Connection Failures
If you can’t connect to MySQL:- Verify MySQL is running:
sudo systemctl status mysql - Test credentials:
mysql -h $DB_HOST -u $DB_USER -p$DB_PASSWORD - Check if the database exists:
SHOW DATABASES; - Verify user permissions:
SHOW GRANTS FOR 'corprecam_user'@'localhost';
Ngrok Authentication Errors
If ngrok fails to connect:- Verify your authtoken is correct
- Check your ngrok account is active at ngrok.com
- Ensure you haven’t exceeded your tunnel limit (2 concurrent on free tier)
Next Steps
Once configuration is complete:- Run the Application - Start the application and test your configuration
- Review the API endpoints in the source code to understand the scraping workflow