https://github.com/ddosnotification/express-raw
Powerful Express.js utility package for better work with express. Zero dependencies.
https://github.com/ddosnotification/express-raw
analytics-tracking bot-detection console-logger developer-tools devtools-detection express express-middleware express-plugin express-utils expressjs monitoring-tool node-middleware nodejs nodejs-logging performance-monitoring request-tracking server-logging user-behavior zero-dependencies
Last synced: about 2 months ago
JSON representation
Powerful Express.js utility package for better work with express. Zero dependencies.
- Host: GitHub
- URL: https://github.com/ddosnotification/express-raw
- Owner: ddosnotification
- Created: 2024-11-25T19:47:40.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-11-27T15:59:45.000Z (6 months ago)
- Last Synced: 2025-01-26T08:26:28.598Z (4 months ago)
- Topics: analytics-tracking, bot-detection, console-logger, developer-tools, devtools-detection, express, express-middleware, express-plugin, express-utils, expressjs, monitoring-tool, node-middleware, nodejs, nodejs-logging, performance-monitoring, request-tracking, server-logging, user-behavior, zero-dependencies
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/express-raw
- Size: 48.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# express-raw
### Advanced Express.js Utilities for Modern Applications
[](https://www.npmjs.com/package/express-raw)
[](https://www.npmjs.com/package/express-raw)
[](https://github.com/ddosnotification/express-raw)*Zero-dependency toolkit for request analytics, performance monitoring, rate limiting, and real-time communication*
---
## ✨ Features
### Core Features
- 🔍 **Request Analytics**
- 🚦 **Rate Limiting**
- 📊 **Enhanced Logging**
- 👁️ **DevTools Detection**### Advanced Features
- 🔌 **WebSocket Support**
- 🎯 **GraphQL Integration**
- 📈 **Metrics Dashboard**
- 🔒 **Security Suite**## 📦 Installation
```bash
npm install express-raw
```Requirements
- Node.js ≥ 14
- Express.js ≥ 4## 🚀 Quick Start
```javascript
const express = require('express');
const {
expressLogger,
RateLimiter,
WebSocketSupport,
MetricsDashboard
} = require('express-raw');const app = express();
// Initialize
const logger = new expressLogger();
const limiter = new RateLimiter({ maxRequests: 100 });
const dashboard = new MetricsDashboard();// Apply middleware
app.use(limiter.middleware(logger));
app.use(logger.middleware());// Start server
app.listen(3000, () => logger.serverStart(3000));
```## 📚 Documentation
### Rate Limiting
Configuration Options
```javascript
const limiter = new RateLimiter({
// Time Window
windowMs: 15 * 60 * 1000, // 15 minutes
maxRequests: 100,
windowType: 'sliding', // 'sliding' | 'fixed'
// Route Limits
routeLimits: {
'/api/auth/.*': 20, // Auth routes: 20 req/window
'/api/upload/.*': 10 // Upload routes: 10 req/window
},
// Security
autoBan: {
enabled: true,
maxViolations: 3, // Ban after 3 violations
banDurationMs: 24 * 60 * 60 * 1000 // 24h
}
});
```### Enhanced Logging
Configuration & Examples
```javascript
const logger = new expressLogger({
enabled: {
server: true, // Server logs
requests: true, // Request logs
responses: true, // Response logs
websocket: true, // WebSocket logs
graphql: true // GraphQL logs
}
});
```#### Output Examples
```shell
# Server Start
[2024-11-25T19:38:20.177Z] ⚡ [SERVER] Server started
Port: 3000
Environment: development
Memory: 8MB# Rate Limit Event
[2024-11-25T19:38:26.177Z] ⚠️ [RATELIMIT] Rate limit exceeded
IP: 192.168.1.100
Path: /api/users
ViolationCount: 1
```### WebSocket Support
```javascript
const wsSupport = new WebSocketSupport({
heartbeatInterval: 30000,
rateLimiting: {
enabled: true,
maxConnectionsPerIP: 5
},
auth: {
enabled: true,
handler: async (req) => {
// Auth logic
}
}
});// Broadcast
wsSupport.broadcast({ type: 'update', data: { time: Date.now() }});
```### GraphQL Integration
```javascript
const profiler = new GraphQLProfiler({
slowQueryThreshold: 500, // ms
maxQueryComplexity: 100,
maxDepth: 10,
trackMemory: true
});app.use('/graphql', profiler.middleware(logger));
```### Metrics Dashboard
```javascript
const dashboard = new MetricsDashboard({
updateInterval: 5000,
enableRealtime: true,
alerts: {
maxMemoryUsage: 85, // %
maxErrorRate: 3 // %
}
});
```## 🎯 Examples
Complete Application Example
```javascript
const express = require('express');
const {
expressLogger,
RateLimiter,
WebSocketSupport,
GraphQLProfiler,
MetricsDashboard
} = require('express-raw');const app = express();
// Initialize components
const logger = new expressLogger({
enabled: {
rateLimit: true,
websocket: true,
graphql: true
}
});const limiter = new RateLimiter({
windowMs: 15 * 60 * 1000,
maxRequests: 100,
autoBan: { enabled: true }
});const wsSupport = new WebSocketSupport({
rateLimiting: { enabled: true }
});const profiler = new GraphQLProfiler({
slowQueryThreshold: 500
});const dashboard = new MetricsDashboard({
enableRealtime: true
});// Apply middleware
app.use(limiter.middleware(logger));
app.use(logger.middleware());
app.use('/graphql', profiler.middleware(logger));
app.use(dashboard.middleware(logger, limiter, profiler));// Start server
const server = app.listen(3000, () => {
logger.serverStart(3000);
});wsSupport.middleware(logger)(server);
```## 📋 Best Practices
### Rate Limiting
- Use sliding windows
- Set route-specific limits
- Enable auto-ban for security
- Whitelist trusted IPs### WebSocket
- Enable heartbeat
- Implement authentication
- Set connection limits
- Handle reconnection### GraphQL
- Set complexity limits
- Monitor slow queries
- Implement depth limiting
- Cache common queries### Dashboard
- Set alert thresholds
- Monitor memory trends
- Keep reasonable retention
- Adjust update frequency## 🔧 Troubleshooting
Common Issues & Solutions
### Rate Limiter
```javascript
// Fix: Too many false positives
const limiter = new RateLimiter({
windowType: 'sliding',
maxRequests: 200
});// Fix: Auto-ban too aggressive
const limiter = new RateLimiter({
autoBan: {
maxViolations: 5,
banDurationMs: 60 * 60 * 1000
}
});
```### WebSocket
```javascript
// Fix: Connection drops
const wsSupport = new WebSocketSupport({
heartbeatInterval: 15000
});// Fix: Memory leaks
const dashboard = new MetricsDashboard({
retentionPeriod: 3600000,
cleanup: true
});
```## 📫 Support
Need help? Found a bug? Have a feature request?
- [GitHub Issues](https://github.com/ddosnotification/express-raw/issues)
---
Made with ♥ by [ZeX](https://github.com/ddosnotification)