| name | express-websocket-backend |
| description | Build Express.js v4.x backends with WebSocket real-time communication, middleware patterns, authentication, API versioning, and production deployment. Focused on backend architecture with Socket.io integration and best practices. |
Express WebSocket Backend Skill
Build production-ready Express.js backends with WebSocket real-time features.
What This Skill Provides
Core Tools
- scaffold_express_api.py - Generate Express.js API structure
- setup_websocket.py - Configure WebSocket with Socket.io
- middleware_generator.py - Create auth, logging, error handling middleware
References
- express_patterns.md - Modern Express.js patterns
- websocket_realtime.md - WebSocket connection management
- best_practices.md - Production Express.js best practices
- advanced_topics.md - Scaling, clustering, monitoring
- troubleshooting.md - Common Express/WebSocket issues
Templates
- Express.js API boilerplate
- WebSocket connection manager
- Authentication middleware
- Error handling middleware
When to Use
Perfect For
- Real-time applications (chat, live updates)
- WebSocket-based features
- Express.js v4.x backends
- Middleware-heavy applications
- API versioning
- Production Express deployments
Not For
- Full-stack apps with frontend (use nodejs-fullstack-setup)
- GraphQL APIs (different patterns)
- Serverless functions (different architecture)
Quick Start
# Scaffold Express API
python scripts/scaffold_express_api.py \
--project-name my-api \
--output-dir ./api
# Setup WebSocket
python scripts/setup_websocket.py \
--project-dir ./api
# Generate middleware
python scripts/middleware_generator.py \
--type auth \
--output ./api/middleware/auth.js
Decision Trees
Which middleware pattern?
- Authentication: JWT tokens, session-based
- Logging: Morgan, Winston
- Error handling: Centralized error middleware
- Rate limiting: Express-rate-limit
Quality Checklist
- Error handling middleware
- Request logging
- Authentication/authorization
- Rate limiting
- CORS configuration
- WebSocket connection management
- Production-ready config
Common Pitfalls
Pitfall: Memory Leaks in WebSocket Connections
Solution: Implement connection cleanup, limit concurrent connections, use heartbeat monitoring.
Pitfall: Blocking Event Loop
Solution: Use async/await, worker threads for CPU-intensive tasks, profiling.
Pro Tips
Tip 1: WebSocket Room Management
io.on('connection', (socket) => {
socket.join(`user_${socket.userId}`);
socket.on('disconnect', () => {
socket.leave(`user_${socket.userId}`);
});
});
Tip 2: Error Handling
app.use((err, req, res, next) => {
logger.error(err.stack);
res.status(err.status || 500).json({
error: err.message
});
});
Related Skills
- nodejs-fullstack-setup - Full-stack with frontend
- fastapi-backend-builder - Python alternative
- testing-infrastructure - Jest/Mocha testing