mle-tools-node
v1.16.4
Published
some node tools
Readme
🛠️ mle-tools-node
A collection of Node.js utilities and tools for building applications
🌟 Features
🚀 High-Performance Task Processing
- Direct execution
- Thread-based processing
- Queue management with retry capabilities
💾 Advanced Caching
- In-memory LRU cache
- Redis integration
- Flexible cache middleware
📊 Monitoring & Metrics
- CPU usage tracking
- Performance metrics
- Time tracking middleware
📝 Logging & Debugging
- Winston-based logging
- Daily rotating log files
- Customizable log levels
- ELK stack integration for log visualization
🔧 Utility Tools
- Secure property management
- CSV processing with fast-csv
- HTTP requests with axios
- Configuration management
📦 Installation
npm install mle-tools-node📚 Documentation
For detailed documentation, please read the specifications.
🚀 Quick Start
import {Logger, Cache, WorkerProcessor} from 'mle-tools-node';
// Set up logging
const logger = new Logger('my-app');
logger.info('Application started');
// Use caching
const cache = new Cache();
await cache.set('key', 'value', 3600); // Cache for 1 hour
const value = await cache.get('key');
// Process tasks
const worker = new WorkerProcessor();
await worker.push('myTask', async () => {
// Your task logic here
});🔧 Configuration
The library can be configured through environment variables or a configuration file:
import {Config} from 'mle-tools-node';
const config = {
cache: {
type: 'redis',
ttl: 3600
},
logging: {
level: 'info',
rotation: true
}
};
Config.initialize(config);🧪 Testing
Run the test suite:
npm testRun with coverage:
npm run test:coverageRun ELK stack integration tests:
npm run test:elkThe test:elk command provides fully automated ELK (Elasticsearch, Logstash, Kibana) stack setup and verification:
- Force Recreation: Completely rebuilds ELK stack with latest configurations
- Volume Verification: Validates mounted log directories (
/app/logs/sample:roand/app/logs/mle-tools:ro) - Integration Testing: Runs logger tests to generate real application logs
- Index Validation: Confirms logs are properly indexed in Elasticsearch with correct @timestamp mapping
- ILM Compliance: Verifies Index Lifecycle Management policies are correctly applied
- Kibana Integration: Automatically creates index patterns and provides direct visualization URLs
- Health Monitoring: Comprehensive health checks for all ELK components
Recent Improvements (v1.14.2):
- ✅ Enhanced thread event handlers in Launcher with proper cleanup to prevent memory leaks
- ✅ Increased process max listeners to prevent warnings when using multiple workers
- ✅ Improved logging consistency with "(mtn)" prefix across CacheMiddleware and LoggerPerf
- ✅ Updated Logstash configuration for better log processing
For detailed ELK integration documentation, see src/logger/logstash/README.md.
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
📝 License
This project is licensed under the MIT License - see the LICENSE file for details.
📈 Release History
See Changelog for a detailed version history.
🏗️ Built With
- TypeScript - Main programming language
- Winston - Logging framework
- Cache Manager - Flexible caching
- Mocha - Testing framework
- Redis - Optional caching backend
🙋♂️ Support
For support, please raise an issue in the GitHub repository or contact the maintainers.
Made with ❤️ by mle
