Core Configuration
This document outlines the primary configuration options for the MS Core system. Proper configuration is essential for optimal performance, security, and functionality.
Environment Settings
NODE_ENV
Specifies the environment in which the application is running. Common values are
production, development, and test. This setting impacts caching, logging levels, and other environment-specific behaviors.
Example:
NODE_ENV=production
PORT
The network port on which the MS Core server will listen for incoming requests. Ensure this port is not already in use.
Example:
PORT=3000
DEBUG
Enables verbose logging for debugging purposes. You can specify specific modules to log by using a comma-separated list. If set to
true or *, all debug messages will be logged.
Example (all debug):
DEBUG=*
Example (specific modules):
DEBUG=ms:core,ms:api
Database Configuration
DATABASE_URL
The connection string for your primary database. This should follow the standard URL format (e.g.,
postgres://user:password@host:port/database).
Example (PostgreSQL):
DATABASE_URL=postgres://admin:secret@localhost:5432/mydatabase
DATABASE_POOL_SIZE
The maximum number of connections to maintain in the database connection pool. Adjust this based on your expected load.
Example:
DATABASE_POOL_SIZE=10
Security Settings
JWT_SECRET
A strong, unique secret key used for signing and verifying JSON Web Tokens (JWTs). This is critical for authentication.
Example (use a strong, random string):
JWT_SECRET=verylongandsecuresecretkeythatshouldbereplaced
Security Tip: Never commit your
JWT_SECRET directly into your source code. Use environment variables or a secrets management system. Generate a new secret for production.
CORS_ORIGINS
A list of allowed origins (domains) for Cross-Origin Resource Sharing (CORS). This prevents unauthorized websites from making requests to your server. Use
* to allow all origins (not recommended for production).
Example (multiple origins):
CORS_ORIGINS=https://example.com,https://app.example.com
Example (all origins - for development only):
CORS_ORIGINS=*
Logging Configuration
LOG_LEVEL
Sets the minimum severity level for logs to be recorded. Common levels include
debug, info, warn, and error.
Example:
LOG_LEVEL=info
LOG_FILE
Specifies a file path where logs should be written. If not set, logs will typically be output to the console.
Example:
LOG_FILE=/var/log/ms_core.log
External Service Integration
EMAIL_SERVICE_PROVIDER
The name of the configured email service provider (e.g.,
SendGrid, Mailgun, SMTP).
Example:
EMAIL_SERVICE_PROVIDER=SendGrid
Configuration can typically be managed using environment variables or a dedicated configuration file (e.g., .env file for local development). For detailed instructions on loading configuration, please refer to the Getting Started guide.