@misterzik/espressojs
Version:
EspressoJS Introducing Espresso.JS, your ultimate Express configuration starting point and boilerplate. With its simplicity and lack of opinionation, EspressoJS offers plug-and-play configurations built on top of Express.
263 lines (206 loc) ⢠7.33 kB
Markdown
# EspressoJS v3.3.0 - Enhancement Summary
This document outlines all the major enhancements made to modernize the EspressoJS framework.
## šÆ Overview
EspressoJS has been upgraded from a basic Express boilerplate to a **production-ready, enterprise-grade framework** with modern security, logging, error handling, and developer experience improvements.
## š Security Enhancements
### Helmet.js Integration
- **Location**: `server/middleware/security.js`
- **Features**:
- Content Security Policy (CSP)
- XSS Protection
- HSTS headers
- Frame protection
- Cross-origin policies
### Rate Limiting
- **General Rate Limit**: 100 requests per 15 minutes
- **API Rate Limit**: 200 requests per 15 minutes
- **Strict Rate Limit**: 10 requests per 15 minutes (for sensitive endpoints)
- Configurable per-route rate limiting
### Enhanced CORS
- Pre-configured CORS middleware
- Customizable origin policies
- Credential support
## š Logging System
### Winston Logger
- **Location**: `server/utils/logger.js`
- **Features**:
- Multiple log levels (error, warn, info, http, debug)
- Color-coded console output
- File-based logging with rotation
- Exception and rejection handlers
### Log Files
- `logs/combined.log` - All application logs
- `logs/error.log` - Error logs only
- `logs/exceptions.log` - Uncaught exceptions
- `logs/rejections.log` - Unhandled promise rejections
### Morgan Integration
- HTTP request logging
- Environment-specific formats (dev/combined)
- Integrated with Winston logger
## š”ļø Error Handling
### Centralized Error Handler
- **Location**: `server/middleware/errorHandler.js`
- **Components**:
- `AppError` class for operational errors
- `errorHandler` middleware for global error handling
- `notFoundHandler` for 404 errors
- `asyncHandler` wrapper for async routes
### Features
- Environment-specific error responses
- Stack traces in development
- Sanitized errors in production
- Proper HTTP status codes
## š„ Health Monitoring
### Health Check Endpoints
- **Location**: `server/middleware/healthCheck.js`
#### `/health`
Comprehensive health check with:
- Server uptime
- Memory usage
- CPU metrics
- Database connection status
- Environment information
#### `/ready`
Readiness probe for orchestration platforms (Kubernetes, Docker Swarm)
#### `/alive`
Liveness probe for monitoring systems
## š§ Configuration Management
### Joi Validation
- **Location**: `server/utils/configValidator.js`
- Schema-based configuration validation
- Type checking and constraints
- Default value handling
- Detailed error messages
### Enhanced Config Utils
- **Location**: `server/utils/config.utils.js`
- Safe file reading with error handling
- Default configuration fallback
- Validated writes
- Better error messages
## š® CLI Improvements
### New Commands
- **Location**: `server/utils/espresso-cli.js`
| Command | Description |
|---------|-------------|
| `init` | Initialize new config.json |
| `validate` | Validate configuration |
| `version` | Show version information |
| `show` | Display current config (enhanced) |
| `run` | Run server (improved) |
| `env` | Update environment (enhanced) |
### Features
- Better error messages with ā/ā indicators
- Improved command help system
- Spawn-based process management
- Proper exit codes
- Input validation
## š Application Improvements
### Main Application (`index.js`)
- Graceful shutdown handling (SIGTERM, SIGINT)
- Proper resource cleanup
- Enhanced startup banner
- Better error handling
- Request body size limits (10MB)
- Improved MongoDB connection handling
### Routes Enhancement
- **Location**: `routes/index.js`
- Async error handling
- Safe file operations
- Better error messages
- Graceful route loading failures
- Default JSON responses
## š¦ Dependency Updates
### New Dependencies
```json
{
"helmet": "^7.1.0",
"morgan": "^1.10.0",
"winston": "^3.11.0",
"express-rate-limit": "^7.1.5",
"express-validator": "^7.0.1",
"joi": "^17.11.0"
}
```
### Updated Dependencies
- `axios`: ^1.4.0 ā ^1.6.0
- `mongoose`: ^7.3.1 ā ^8.0.3
## š Documentation
### New Documentation Files
- `README.md` - Comprehensive documentation (completely rewritten)
- `QUICKSTART.md` - 5-minute quick start guide
- `CHANGELOG.md` - Version history and changes
- `CONTRIBUTING.md` - Contribution guidelines
- `ENHANCEMENTS.md` - This file
### Example Files
- `examples/basic-api.js` - REST API examples
- `examples/mongodb-example.js` - MongoDB integration
- `examples/README.md` - Examples documentation
## šØ Developer Experience
### Improved Startup
```
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā ESPRESSO.JS ā
ā Express Boilerplate Server ā
ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā£
ā Environment: development ā
ā Port: 8080 ā
ā URL: http://localhost:8080 ā
ā MongoDB: Disabled ā
ā API: Disabled ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
```
### Better Error Messages
- Descriptive validation errors
- Helpful CLI feedback
- Color-coded console output
- Stack traces in development
## š Breaking Changes
### None!
All changes are backward compatible. Existing EspressoJS projects will continue to work without modifications.
## š Performance Improvements
- Compression enabled by default
- Static file caching (1 day max-age)
- ETags enabled
- Request size limits prevent memory issues
- Efficient logging with Winston
## š ļø Migration Guide
### From v3.2.6 to v3.3.0
1. **Update dependencies**:
```bash
npm install
```
2. **Optional: Use new CLI commands**:
```bash
node cli validate # Check your config
node cli version # See version info
```
3. **Optional: Add health checks to monitoring**:
- Add `/health` to your monitoring system
- Use `/ready` and `/alive` for orchestration
4. **Optional: Use new middleware**:
```javascript
const { asyncHandler, AppError } = require('./server/middleware/errorHandler');
const logger = require('./server/utils/logger');
```
## šÆ Future Roadmap
Potential future enhancements:
- TypeScript support
- WebSocket integration
- GraphQL support
- Built-in testing framework
- Docker configuration
- CI/CD templates
- Swagger/OpenAPI documentation
- Redis caching support
- Session management
- Authentication middleware
## š Acknowledgments
Built with modern Express.js best practices and inspired by production-grade Node.js applications.
## š Support
- GitHub: https://github.com/misterzik/Espresso.js
- Issues: https://github.com/misterzik/Espresso.js/issues
- npm: https://www.npmjs.com/package/@misterzik/espressojs
---
**Version**: 3.3.0
**Release Date**: 2024
**License**: MIT