Environment Variables Reference
All configuration is managed through environment variables defined in a.env file.
Server Configuration
PORT
The port number where the Express server will listen.- Type: Number
- Default: 3005 (src/index.ts:4)
- Required: No
Database Configuration
DATABASE_URL
PostgreSQL connection string used by Sequelize ORM.- Type: String (PostgreSQL connection URI)
- Required: Yes
- Used in: src/config/db.ts:5
- Format:
postgresql://[user]:[password]@[host]:[port]/[database]
JWT Authentication
JWT_SECRET
Secret key used to sign and verify JSON Web Tokens for user authentication.- Type: String
- Required: Yes
- Used in:
- src/utils/jwt.ts:4 - Token generation
- src/middleware/auth.ts:31 - Token verification
- Token Expiration: 30 days (src/utils/jwt.ts:5)
Email Configuration (Nodemailer)
The application uses Nodemailer for sending emails (account confirmation, password reset, etc.).EMAIL_HOST
SMTP server hostname.- Type: String
- Required: Yes
- Used in: src/config/nodemailer.ts:16
EMAIL_PORT
SMTP server port number.- Type: Number
- Required: Yes
- Used in: src/config/nodemailer.ts:17
- Common values:
587- TLS/STARTTLS (recommended)465- SSL25- Unencrypted (not recommended)
EMAIL_USER
SMTP authentication username (usually your email address).- Type: String
- Required: Yes
- Used in: src/config/nodemailer.ts:19
EMAIL_PASS
SMTP authentication password or app-specific password.- Type: String
- Required: Yes
- Used in: src/config/nodemailer.ts:20
For Gmail, you must use an App Password, not your regular password.
FRONTEND_URL
The URL of your frontend application, used in email links and CORS configuration.- Type: String (URL)
- Required: Yes
- Used in: Email templates for confirmation and password reset links
CORS Configuration
Cross-Origin Resource Sharing (CORS) is configured insrc/server.ts.
Current Configuration
Configuration Options
| Option | Value | Description |
|---|---|---|
origin | Array of URLs | Allowed origins for cross-origin requests |
credentials | true | Allows cookies and authentication headers |
Customizing CORS
To allow additional origins, modify theorigin array:
Dynamic CORS (Environment-based)
For better flexibility, use environment variables:Rate Limiting Configuration
Rate limiting prevents abuse by limiting the number of requests from a single IP.Current Configuration
Configuration Options
| Option | Value | Description |
|---|---|---|
windowMs | 60000 (1 minute) | Time window for rate limiting |
limit | 5 | Maximum requests per window |
message | Custom JSON | Response when limit exceeded |
Where It’s Applied
The rate limiter is currently applied to all authentication routes:/api/auth/* endpoints are limited to 5 requests per minute.
Customizing Rate Limits
Database Connection Configuration
Sequelize ORM manages the database connection.Current Configuration
Configuration Options
| Option | Value | Description |
|---|---|---|
| Connection String | process.env.DATABASE_URL | PostgreSQL connection URI |
models | [__dirname + '/../models/**/*'] | Path to model files |
logging | false | Disable SQL query logging |
Enable SQL Logging (Development)
For debugging, enable SQL query logging:Connection Pool Configuration
For production, configure connection pooling:Security Configuration
Helmet (Security Headers)
Helmet sets various HTTP headers for security.Content-Security-PolicyX-DNS-Prefetch-ControlX-Frame-OptionsX-Content-Type-Options- And more…
Authentication Middleware
JWT authentication is handled by theauthenticate middleware:
Complete Configuration Example
Next Steps
Deployment
Learn how to deploy to production
API Reference
Explore API endpoints