pms_md 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +93 -0
- package/node-monitor/ARCHITECTURE.md +341 -0
- package/node-monitor/CHANGELOG.md +105 -0
- package/node-monitor/CONTRIBUTING.md +96 -0
- package/node-monitor/DESIGN_IMPROVEMENTS.md +286 -0
- package/node-monitor/FILTER_BUTTONS_FIX.md +303 -0
- package/node-monitor/GETTING_STARTED.md +416 -0
- package/node-monitor/INSTALLATION.md +470 -0
- package/node-monitor/LICENSE +22 -0
- package/node-monitor/PUBLISHING_GUIDE.md +331 -0
- package/node-monitor/QUICK_REFERENCE.md +252 -0
- package/node-monitor/README.md +458 -0
- package/node-monitor/READY_TO_PUBLISH.md +272 -0
- package/node-monitor/SETUP_GUIDE.md +479 -0
- package/node-monitor/examples/EMAIL_SETUP_GUIDE.md +282 -0
- package/node-monitor/examples/ERROR_LOGGING_GUIDE.md +405 -0
- package/node-monitor/examples/GET_APP_PASSWORD.md +145 -0
- package/node-monitor/examples/LOG_FILES_REFERENCE.md +336 -0
- package/node-monitor/examples/QUICK_START_EMAIL.md +126 -0
- package/node-monitor/examples/express-app.js +499 -0
- package/node-monitor/examples/package-lock.json +1295 -0
- package/node-monitor/examples/package.json +18 -0
- package/node-monitor/examples/public/css/style.css +718 -0
- package/node-monitor/examples/public/js/dashboard.js +207 -0
- package/node-monitor/examples/public/js/health.js +114 -0
- package/node-monitor/examples/public/js/main.js +89 -0
- package/node-monitor/examples/public/js/metrics.js +225 -0
- package/node-monitor/examples/public/js/theme.js +138 -0
- package/node-monitor/examples/views/dashboard.ejs +20 -0
- package/node-monitor/examples/views/error-logs.ejs +1129 -0
- package/node-monitor/examples/views/health.ejs +21 -0
- package/node-monitor/examples/views/home.ejs +341 -0
- package/node-monitor/examples/views/layout.ejs +50 -0
- package/node-monitor/examples/views/metrics.ejs +16 -0
- package/node-monitor/examples/views/partials/footer.ejs +16 -0
- package/node-monitor/examples/views/partials/header.ejs +35 -0
- package/node-monitor/examples/views/partials/nav.ejs +23 -0
- package/node-monitor/examples/views/status.ejs +390 -0
- package/node-monitor/package-lock.json +4300 -0
- package/node-monitor/package.json +76 -0
- package/node-monitor/pre-publish-check.js +200 -0
- package/node-monitor/src/config/monitoringConfig.js +255 -0
- package/node-monitor/src/index.js +300 -0
- package/node-monitor/src/logger/errorLogger.js +297 -0
- package/node-monitor/src/monitors/apiErrorMonitor.js +156 -0
- package/node-monitor/src/monitors/dbConnectionMonitor.js +389 -0
- package/node-monitor/src/monitors/serverHealthMonitor.js +320 -0
- package/node-monitor/src/monitors/systemResourceMonitor.js +357 -0
- package/node-monitor/src/notifiers/emailNotifier.js +248 -0
- package/node-monitor/src/notifiers/notificationManager.js +96 -0
- package/node-monitor/src/notifiers/slackNotifier.js +209 -0
- package/node-monitor/src/views/dashboard.html +530 -0
- package/node-monitor/src/views/health.html +399 -0
- package/node-monitor/src/views/metrics.html +406 -0
- package/package.json +22 -0
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
# 🚀 Node Monitor
|
|
2
|
+
|
|
3
|
+
A comprehensive, production-ready monitoring solution for Node.js applications with error tracking, health checks, system resource monitoring, database connection monitoring, and multi-channel notifications.
|
|
4
|
+
|
|
5
|
+
## ✨ Features
|
|
6
|
+
|
|
7
|
+
- **🔍 API Error Tracking** - Automatic error logging and tracking with Express/Fastify middleware
|
|
8
|
+
- **💓 Server Health Monitoring** - Heartbeat mechanism with customizable health checks
|
|
9
|
+
- **📊 System Resource Monitoring** - CPU, memory, and event loop monitoring with configurable thresholds
|
|
10
|
+
- **🗄️ Database Connection Monitoring** - Support for MongoDB, PostgreSQL, MySQL, and Redis
|
|
11
|
+
- **📧 Multi-Channel Notifications** - Email, Slack, and SMS alerts
|
|
12
|
+
- **📝 Advanced Logging** - Winston-based logging with rotation and sanitization
|
|
13
|
+
- **⚙️ Highly Configurable** - Environment variables and programmatic configuration
|
|
14
|
+
- **🔒 Security-First** - Sensitive data sanitization and secure credential handling
|
|
15
|
+
- **📈 Metrics & Analytics** - Historical metrics tracking and dashboard endpoints
|
|
16
|
+
- **🎯 Zero Dependencies Overhead** - Peer dependencies for database drivers (install only what you need)
|
|
17
|
+
|
|
18
|
+
## 📦 Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install @projectmd/node-monitor
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Optional Peer Dependencies
|
|
25
|
+
|
|
26
|
+
Install only the database drivers you need:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
# For MongoDB/Mongoose
|
|
30
|
+
npm install mongoose
|
|
31
|
+
|
|
32
|
+
# For PostgreSQL
|
|
33
|
+
npm install pg
|
|
34
|
+
|
|
35
|
+
# For MySQL
|
|
36
|
+
npm install mysql2
|
|
37
|
+
|
|
38
|
+
# For Redis
|
|
39
|
+
npm install ioredis
|
|
40
|
+
|
|
41
|
+
# For Express (if not already installed)
|
|
42
|
+
npm install express
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## 🚀 Quick Start
|
|
46
|
+
|
|
47
|
+
### Basic Setup
|
|
48
|
+
|
|
49
|
+
```javascript
|
|
50
|
+
const express = require('express');
|
|
51
|
+
const NodeMonitor = require('@projectmd/node-monitor');
|
|
52
|
+
|
|
53
|
+
// Initialize monitor
|
|
54
|
+
const monitor = new NodeMonitor({
|
|
55
|
+
app: {
|
|
56
|
+
name: 'My App',
|
|
57
|
+
version: '1.0.0'
|
|
58
|
+
},
|
|
59
|
+
notifications: {
|
|
60
|
+
email: {
|
|
61
|
+
enabled: true,
|
|
62
|
+
host: 'smtp.gmail.com',
|
|
63
|
+
port: 587,
|
|
64
|
+
auth: {
|
|
65
|
+
user: 'your-email@gmail.com',
|
|
66
|
+
pass: 'your-app-password'
|
|
67
|
+
},
|
|
68
|
+
recipients: ['admin@example.com']
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const app = express();
|
|
74
|
+
|
|
75
|
+
// Add monitoring middleware
|
|
76
|
+
app.use(monitor.requestLogger());
|
|
77
|
+
|
|
78
|
+
// Add health check endpoint
|
|
79
|
+
app.get('/health', monitor.healthCheckEndpoint());
|
|
80
|
+
|
|
81
|
+
// Your routes here
|
|
82
|
+
app.get('/', (req, res) => {
|
|
83
|
+
res.json({ message: 'Hello World' });
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// Error handling (must be last)
|
|
87
|
+
app.use(monitor.notFoundHandler());
|
|
88
|
+
app.use(monitor.errorMiddleware());
|
|
89
|
+
|
|
90
|
+
// Start server
|
|
91
|
+
const server = app.listen(3000, () => {
|
|
92
|
+
console.log('Server running on port 3000');
|
|
93
|
+
|
|
94
|
+
// Start monitoring
|
|
95
|
+
monitor.start();
|
|
96
|
+
|
|
97
|
+
// Setup graceful shutdown
|
|
98
|
+
monitor.setupGracefulShutdown(server);
|
|
99
|
+
});
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## 📖 Configuration
|
|
103
|
+
|
|
104
|
+
### Environment Variables
|
|
105
|
+
|
|
106
|
+
Create a `.env` file (see `.env.example` for all options):
|
|
107
|
+
|
|
108
|
+
```env
|
|
109
|
+
# Application
|
|
110
|
+
MONITOR_APP_NAME=my-app
|
|
111
|
+
NODE_ENV=production
|
|
112
|
+
|
|
113
|
+
# Thresholds
|
|
114
|
+
MONITOR_CPU_THRESHOLD=80
|
|
115
|
+
MONITOR_MEMORY_THRESHOLD=90
|
|
116
|
+
MONITOR_ERROR_RATE_THRESHOLD=50
|
|
117
|
+
|
|
118
|
+
# Email Notifications
|
|
119
|
+
MONITOR_EMAIL_ENABLED=true
|
|
120
|
+
MONITOR_EMAIL_HOST=smtp.gmail.com
|
|
121
|
+
MONITOR_EMAIL_USER=your-email@gmail.com
|
|
122
|
+
MONITOR_EMAIL_PASS=your-password
|
|
123
|
+
MONITOR_EMAIL_RECIPIENTS=admin@example.com
|
|
124
|
+
|
|
125
|
+
# Slack Notifications
|
|
126
|
+
MONITOR_SLACK_ENABLED=true
|
|
127
|
+
MONITOR_SLACK_WEBHOOK=https://hooks.slack.com/services/YOUR/WEBHOOK
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Programmatic Configuration
|
|
131
|
+
|
|
132
|
+
```javascript
|
|
133
|
+
const monitor = new NodeMonitor({
|
|
134
|
+
intervals: {
|
|
135
|
+
health: 60000, // 1 minute
|
|
136
|
+
system: 300000, // 5 minutes
|
|
137
|
+
database: 120000 // 2 minutes
|
|
138
|
+
},
|
|
139
|
+
|
|
140
|
+
thresholds: {
|
|
141
|
+
cpu: 80,
|
|
142
|
+
memory: 90,
|
|
143
|
+
errorRate: 50,
|
|
144
|
+
responseTime: 5000,
|
|
145
|
+
consecutiveFailures: 3
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
notifications: {
|
|
149
|
+
enabled: true,
|
|
150
|
+
cooldown: 300000, // 5 minutes
|
|
151
|
+
|
|
152
|
+
email: { /* ... */ },
|
|
153
|
+
slack: { /* ... */ }
|
|
154
|
+
},
|
|
155
|
+
|
|
156
|
+
logging: {
|
|
157
|
+
enabled: true,
|
|
158
|
+
level: 'info',
|
|
159
|
+
directory: './logs'
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## 🎯 Usage Examples
|
|
165
|
+
|
|
166
|
+
### API Error Tracking
|
|
167
|
+
|
|
168
|
+
```javascript
|
|
169
|
+
// Automatic error tracking with middleware
|
|
170
|
+
app.use(monitor.errorMiddleware());
|
|
171
|
+
|
|
172
|
+
// Manual error logging
|
|
173
|
+
app.get('/api/data', async (req, res, next) => {
|
|
174
|
+
try {
|
|
175
|
+
const data = await fetchData();
|
|
176
|
+
res.json(data);
|
|
177
|
+
} catch (error) {
|
|
178
|
+
monitor.logError('data_fetch_failed', error.message, {
|
|
179
|
+
userId: req.user?.id
|
|
180
|
+
});
|
|
181
|
+
next(error);
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
// Async handler wrapper
|
|
186
|
+
app.get('/api/users', monitor.asyncHandler(async (req, res) => {
|
|
187
|
+
const users = await User.find();
|
|
188
|
+
res.json(users);
|
|
189
|
+
}));
|
|
190
|
+
|
|
191
|
+
// Create custom errors
|
|
192
|
+
const error = NodeMonitor.createError('Not found', 404);
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Health Checks
|
|
196
|
+
|
|
197
|
+
```javascript
|
|
198
|
+
// Register custom health checks
|
|
199
|
+
monitor.registerHealthCheck('database', async () => {
|
|
200
|
+
try {
|
|
201
|
+
await db.ping();
|
|
202
|
+
return true;
|
|
203
|
+
} catch {
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
monitor.registerHealthCheck('external-api', async () => {
|
|
209
|
+
const response = await fetch('https://api.example.com/health');
|
|
210
|
+
return response.ok;
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
// Health check endpoint
|
|
214
|
+
app.get('/health', monitor.healthCheckEndpoint());
|
|
215
|
+
|
|
216
|
+
// Basic health info
|
|
217
|
+
app.get('/health/info', monitor.healthInfoEndpoint());
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### Database Monitoring
|
|
221
|
+
|
|
222
|
+
```javascript
|
|
223
|
+
// MongoDB/Mongoose
|
|
224
|
+
const mongoose = require('mongoose');
|
|
225
|
+
await mongoose.connect('mongodb://localhost:27017/myapp');
|
|
226
|
+
monitor.registerDatabase('mongodb', 'mongoose', mongoose.connection);
|
|
227
|
+
|
|
228
|
+
// PostgreSQL
|
|
229
|
+
const { Pool } = require('pg');
|
|
230
|
+
const pgPool = new Pool({ connectionString: 'postgresql://...' });
|
|
231
|
+
monitor.registerDatabase('postgres', 'postgresql', pgPool);
|
|
232
|
+
|
|
233
|
+
// MySQL
|
|
234
|
+
const mysql = require('mysql2/promise');
|
|
235
|
+
const mysqlPool = mysql.createPool({ /* config */ });
|
|
236
|
+
monitor.registerDatabase('mysql', 'mysql', mysqlPool);
|
|
237
|
+
|
|
238
|
+
// Redis
|
|
239
|
+
const Redis = require('ioredis');
|
|
240
|
+
const redis = new Redis();
|
|
241
|
+
monitor.registerDatabase('redis', 'redis', redis);
|
|
242
|
+
|
|
243
|
+
// Get database stats
|
|
244
|
+
const stats = await monitor.getDatabaseStats('mongodb');
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### System Monitoring
|
|
248
|
+
|
|
249
|
+
```javascript
|
|
250
|
+
// Get current metrics
|
|
251
|
+
const metrics = monitor.getStatus();
|
|
252
|
+
console.log(metrics.system); // { cpu: {...}, memory: {...} }
|
|
253
|
+
|
|
254
|
+
// Get system information
|
|
255
|
+
const sysInfo = monitor.getSystemInfo();
|
|
256
|
+
|
|
257
|
+
// Get metrics history
|
|
258
|
+
const history = monitor.getMetricsHistory();
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### Custom Notifications
|
|
262
|
+
|
|
263
|
+
```javascript
|
|
264
|
+
// Send custom notifications
|
|
265
|
+
await monitor.notify('critical', 'Payment Failed',
|
|
266
|
+
'Payment processing system is down',
|
|
267
|
+
{ transactionId: '12345' }
|
|
268
|
+
);
|
|
269
|
+
|
|
270
|
+
await monitor.notify('warning', 'High Traffic',
|
|
271
|
+
'Traffic spike detected',
|
|
272
|
+
{ requestsPerMinute: 10000 }
|
|
273
|
+
);
|
|
274
|
+
|
|
275
|
+
await monitor.notify('info', 'Deployment Complete',
|
|
276
|
+
'Version 2.0.0 deployed successfully'
|
|
277
|
+
);
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### Monitoring Dashboard
|
|
281
|
+
|
|
282
|
+
```javascript
|
|
283
|
+
// JSON dashboard endpoint
|
|
284
|
+
app.get('/monitor/dashboard', monitor.dashboardEndpoint());
|
|
285
|
+
|
|
286
|
+
// Custom dashboard
|
|
287
|
+
app.get('/admin/monitor', (req, res) => {
|
|
288
|
+
const status = monitor.getStatus();
|
|
289
|
+
const systemInfo = monitor.getSystemInfo();
|
|
290
|
+
|
|
291
|
+
res.render('dashboard', { status, systemInfo });
|
|
292
|
+
});
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## 📊 API Reference
|
|
296
|
+
|
|
297
|
+
### Main Methods
|
|
298
|
+
|
|
299
|
+
#### `monitor.start()`
|
|
300
|
+
Start all monitoring services (health checks, system monitoring, database monitoring).
|
|
301
|
+
|
|
302
|
+
#### `monitor.stop()`
|
|
303
|
+
Stop all monitoring services.
|
|
304
|
+
|
|
305
|
+
#### `monitor.getStatus()`
|
|
306
|
+
Get current monitoring status including health, system metrics, database status, and error stats.
|
|
307
|
+
|
|
308
|
+
#### `monitor.notify(level, subject, message, details)`
|
|
309
|
+
Send notification through all enabled channels.
|
|
310
|
+
- `level`: 'critical', 'warning', 'info', or 'recovery'
|
|
311
|
+
|
|
312
|
+
### Middleware
|
|
313
|
+
|
|
314
|
+
#### `monitor.errorMiddleware()`
|
|
315
|
+
Express error handling middleware. Must be added last.
|
|
316
|
+
|
|
317
|
+
#### `monitor.requestLogger()`
|
|
318
|
+
Logs all requests and tracks slow responses.
|
|
319
|
+
|
|
320
|
+
#### `monitor.notFoundHandler()`
|
|
321
|
+
404 handler middleware.
|
|
322
|
+
|
|
323
|
+
#### `monitor.asyncHandler(fn)`
|
|
324
|
+
Wraps async route handlers to catch errors.
|
|
325
|
+
|
|
326
|
+
### Health Monitoring
|
|
327
|
+
|
|
328
|
+
#### `monitor.registerHealthCheck(name, checkFunction)`
|
|
329
|
+
Register a custom health check.
|
|
330
|
+
|
|
331
|
+
#### `monitor.healthCheckEndpoint()`
|
|
332
|
+
Returns Express middleware for `/health` endpoint.
|
|
333
|
+
|
|
334
|
+
#### `monitor.setupGracefulShutdown(server)`
|
|
335
|
+
Setup graceful shutdown handlers for SIGTERM/SIGINT.
|
|
336
|
+
|
|
337
|
+
### Database Monitoring
|
|
338
|
+
|
|
339
|
+
#### `monitor.registerDatabase(name, type, connection, testQuery)`
|
|
340
|
+
Register a database connection for monitoring.
|
|
341
|
+
- `type`: 'mongoose', 'postgresql', 'mysql', or 'redis'
|
|
342
|
+
|
|
343
|
+
#### `monitor.getDatabaseStats(name)`
|
|
344
|
+
Get statistics for a specific database connection.
|
|
345
|
+
|
|
346
|
+
### Logging
|
|
347
|
+
|
|
348
|
+
#### `monitor.logError(type, message, details)`
|
|
349
|
+
Log a custom error.
|
|
350
|
+
|
|
351
|
+
#### `monitor.logWarning(type, message, details)`
|
|
352
|
+
Log a warning.
|
|
353
|
+
|
|
354
|
+
#### `monitor.logInfo(message, details)`
|
|
355
|
+
Log informational message.
|
|
356
|
+
|
|
357
|
+
#### `monitor.getLogger()`
|
|
358
|
+
Get Winston logger instance for advanced usage.
|
|
359
|
+
|
|
360
|
+
## 🔔 Notification Channels
|
|
361
|
+
|
|
362
|
+
### Email (Nodemailer)
|
|
363
|
+
|
|
364
|
+
```javascript
|
|
365
|
+
notifications: {
|
|
366
|
+
email: {
|
|
367
|
+
enabled: true,
|
|
368
|
+
host: 'smtp.gmail.com',
|
|
369
|
+
port: 587,
|
|
370
|
+
secure: false,
|
|
371
|
+
auth: {
|
|
372
|
+
user: 'your-email@gmail.com',
|
|
373
|
+
pass: 'your-app-password'
|
|
374
|
+
},
|
|
375
|
+
from: 'alerts@myapp.com',
|
|
376
|
+
recipients: ['admin@example.com', 'ops@example.com']
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
### Slack
|
|
382
|
+
|
|
383
|
+
```javascript
|
|
384
|
+
notifications: {
|
|
385
|
+
slack: {
|
|
386
|
+
enabled: true,
|
|
387
|
+
webhook: 'https://hooks.slack.com/services/YOUR/WEBHOOK/URL',
|
|
388
|
+
channel: '#monitoring',
|
|
389
|
+
username: 'Node Monitor'
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
## 🔒 Security Features
|
|
395
|
+
|
|
396
|
+
- **Sensitive Data Sanitization** - Automatically redacts passwords, tokens, API keys from logs
|
|
397
|
+
- **Environment Variable Support** - Keep credentials out of code
|
|
398
|
+
- **Configurable Fields** - Customize which fields to sanitize
|
|
399
|
+
- **Secure Communication** - HTTPS for webhooks, TLS for email
|
|
400
|
+
|
|
401
|
+
## 📈 Monitoring Endpoints
|
|
402
|
+
|
|
403
|
+
| Endpoint | Description |
|
|
404
|
+
|----------|-------------|
|
|
405
|
+
| `/health` | Full health check with all registered checks |
|
|
406
|
+
| `/health/info` | Basic health information |
|
|
407
|
+
| `/monitor/dashboard` | Complete monitoring dashboard (JSON) |
|
|
408
|
+
| `/monitor/status` | Current monitoring status |
|
|
409
|
+
| `/monitor/system` | System information |
|
|
410
|
+
| `/monitor/metrics` | Historical metrics |
|
|
411
|
+
|
|
412
|
+
## 🎨 Example Output
|
|
413
|
+
|
|
414
|
+
### Health Check Response
|
|
415
|
+
```json
|
|
416
|
+
{
|
|
417
|
+
"status": "healthy",
|
|
418
|
+
"timestamp": "2024-01-15T10:30:00.000Z",
|
|
419
|
+
"uptime": "2d 5h 30m 15s",
|
|
420
|
+
"checks": {
|
|
421
|
+
"database": { "status": "pass" },
|
|
422
|
+
"external-api": { "status": "pass" }
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
### Dashboard Response
|
|
428
|
+
```json
|
|
429
|
+
{
|
|
430
|
+
"status": "ok",
|
|
431
|
+
"application": {
|
|
432
|
+
"name": "My App",
|
|
433
|
+
"version": "1.0.0",
|
|
434
|
+
"environment": "production"
|
|
435
|
+
},
|
|
436
|
+
"monitoring": {
|
|
437
|
+
"isRunning": true,
|
|
438
|
+
"health": { "isHealthy": true, "uptime": "2d 5h" },
|
|
439
|
+
"system": {
|
|
440
|
+
"cpu": { "process": 15.5, "system": 45.2 },
|
|
441
|
+
"memory": { "system": { "usagePercent": 65.3 } }
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
## 📝 License
|
|
448
|
+
|
|
449
|
+
MIT
|
|
450
|
+
|
|
451
|
+
## 🤝 Contributing
|
|
452
|
+
|
|
453
|
+
Contributions welcome! Please read our contributing guidelines first.
|
|
454
|
+
|
|
455
|
+
## 📞 Support
|
|
456
|
+
|
|
457
|
+
For issues and questions, please open an issue on GitHub.
|
|
458
|
+
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
# 🎉 Your Package is Ready to Publish!
|
|
2
|
+
|
|
3
|
+
## ✅ What We've Done
|
|
4
|
+
|
|
5
|
+
### 1. Created `.npmignore` File ✅
|
|
6
|
+
- Excludes development files, logs, and sensitive data
|
|
7
|
+
- Keeps package size small (81.7 kB)
|
|
8
|
+
- Located at: `node-monitor/.npmignore`
|
|
9
|
+
|
|
10
|
+
### 2. Updated `package.json` ✅
|
|
11
|
+
Added the following fields:
|
|
12
|
+
- **Repository:** `git+https://github.com/projectmd/node-monitor.git`
|
|
13
|
+
- **Bugs URL:** `https://github.com/projectmd/node-monitor/issues`
|
|
14
|
+
- **Homepage:** `https://github.com/projectmd/node-monitor#readme`
|
|
15
|
+
- **Additional Keywords:** Added more keywords for better discoverability
|
|
16
|
+
- **Scripts:** Added `prepublishOnly` and `version` scripts
|
|
17
|
+
|
|
18
|
+
### 3. Created Publishing Tools ✅
|
|
19
|
+
- **PUBLISHING_GUIDE.md** - Complete step-by-step publishing guide
|
|
20
|
+
- **pre-publish-check.js** - Validation script to check package readiness
|
|
21
|
+
- **READY_TO_PUBLISH.md** - This file!
|
|
22
|
+
|
|
23
|
+
### 4. Ran Pre-Publish Checks ✅
|
|
24
|
+
All checks passed:
|
|
25
|
+
- ✅ Package name: `@projectmd/node-monitor`
|
|
26
|
+
- ✅ Version: `1.0.0`
|
|
27
|
+
- ✅ Main entry point exists
|
|
28
|
+
- ✅ README.md exists (10,526 characters)
|
|
29
|
+
- ✅ LICENSE file exists (MIT)
|
|
30
|
+
- ✅ .npmignore configured
|
|
31
|
+
- ✅ No sensitive files
|
|
32
|
+
- ✅ 10 source files ready
|
|
33
|
+
- ✅ Dependencies installed
|
|
34
|
+
|
|
35
|
+
### 5. Ran Dry Run ✅
|
|
36
|
+
Package details:
|
|
37
|
+
- **Package size:** 81.7 kB (compressed)
|
|
38
|
+
- **Unpacked size:** 346.1 kB
|
|
39
|
+
- **Total files:** 47 files
|
|
40
|
+
- **Includes:** Source code, documentation, examples, views
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## 📦 What Will Be Published
|
|
45
|
+
|
|
46
|
+
### Included Files (47 total):
|
|
47
|
+
|
|
48
|
+
**Documentation:**
|
|
49
|
+
- ARCHITECTURE.md
|
|
50
|
+
- CHANGELOG.md
|
|
51
|
+
- CONTRIBUTING.md
|
|
52
|
+
- GETTING_STARTED.md
|
|
53
|
+
- INSTALLATION.md
|
|
54
|
+
- LICENSE
|
|
55
|
+
- PUBLISHING_GUIDE.md
|
|
56
|
+
- QUICK_REFERENCE.md
|
|
57
|
+
- README.md
|
|
58
|
+
- SETUP_GUIDE.md
|
|
59
|
+
|
|
60
|
+
**Source Code:**
|
|
61
|
+
- src/index.js (main entry point)
|
|
62
|
+
- src/config/monitoringConfig.js
|
|
63
|
+
- src/logger/errorLogger.js
|
|
64
|
+
- src/monitors/ (4 monitor files)
|
|
65
|
+
- src/notifiers/ (3 notifier files)
|
|
66
|
+
- src/views/ (3 HTML templates)
|
|
67
|
+
|
|
68
|
+
**Examples:**
|
|
69
|
+
- examples/express-app.js
|
|
70
|
+
- examples/package.json
|
|
71
|
+
- examples/views/ (EJS templates)
|
|
72
|
+
- examples/public/ (CSS and JS files)
|
|
73
|
+
- examples/EMAIL_SETUP_GUIDE.md
|
|
74
|
+
- examples/ERROR_LOGGING_GUIDE.md
|
|
75
|
+
- examples/GET_APP_PASSWORD.md
|
|
76
|
+
- examples/LOG_FILES_REFERENCE.md
|
|
77
|
+
- examples/QUICK_START_EMAIL.md
|
|
78
|
+
|
|
79
|
+
**Package Files:**
|
|
80
|
+
- package.json
|
|
81
|
+
- pre-publish-check.js
|
|
82
|
+
|
|
83
|
+
### Excluded Files (via .npmignore):
|
|
84
|
+
- ❌ node_modules/
|
|
85
|
+
- ❌ examples/node_modules/
|
|
86
|
+
- ❌ examples/logs/
|
|
87
|
+
- ❌ .env files
|
|
88
|
+
- ❌ logs/
|
|
89
|
+
- ❌ Test files
|
|
90
|
+
- ❌ IDE configuration
|
|
91
|
+
- ❌ BUILD_COMPLETE.md
|
|
92
|
+
- ❌ PROJECT_SUMMARY.md
|
|
93
|
+
- ❌ RUNNING_GUIDE.md
|
|
94
|
+
- ❌ EJS_UI_GUIDE.md
|
|
95
|
+
- ❌ UI_GUIDE.md
|
|
96
|
+
- ❌ test-ui.ps1
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## 🚀 Ready to Publish!
|
|
101
|
+
|
|
102
|
+
### Quick Publish Steps:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
# 1. Login to npm (if not already logged in)
|
|
106
|
+
npm login
|
|
107
|
+
|
|
108
|
+
# 2. Verify you're logged in
|
|
109
|
+
npm whoami
|
|
110
|
+
|
|
111
|
+
# 3. Publish the package
|
|
112
|
+
npm publish --access public
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Detailed Steps:
|
|
116
|
+
|
|
117
|
+
See **PUBLISHING_GUIDE.md** for complete instructions.
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## 📊 Package Information
|
|
122
|
+
|
|
123
|
+
```json
|
|
124
|
+
{
|
|
125
|
+
"name": "@projectmd/node-monitor",
|
|
126
|
+
"version": "1.0.0",
|
|
127
|
+
"description": "Comprehensive monitoring solution for Node.js applications",
|
|
128
|
+
"main": "src/index.js",
|
|
129
|
+
"license": "MIT",
|
|
130
|
+
"repository": "git+https://github.com/projectmd/node-monitor.git"
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**Package Size:** 81.7 kB
|
|
135
|
+
**Unpacked Size:** 346.1 kB
|
|
136
|
+
**Total Files:** 47
|
|
137
|
+
**Node Version:** >=14.0.0
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## 🔗 After Publishing
|
|
142
|
+
|
|
143
|
+
Once published, your package will be available at:
|
|
144
|
+
|
|
145
|
+
**npm Package Page:**
|
|
146
|
+
```
|
|
147
|
+
https://www.npmjs.com/package/@projectmd/node-monitor
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
**Installation Command:**
|
|
151
|
+
```bash
|
|
152
|
+
npm install @projectmd/node-monitor
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
**Usage:**
|
|
156
|
+
```javascript
|
|
157
|
+
const NodeMonitor = require('@projectmd/node-monitor');
|
|
158
|
+
const monitor = new NodeMonitor();
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## 📝 Important Notes
|
|
164
|
+
|
|
165
|
+
### Before Publishing:
|
|
166
|
+
|
|
167
|
+
1. **Update GitHub Repository URL** (if different):
|
|
168
|
+
- Edit `package.json` lines 30-37
|
|
169
|
+
- Replace `projectmd/node-monitor` with your actual GitHub username/repo
|
|
170
|
+
|
|
171
|
+
2. **Create GitHub Repository** (if not exists):
|
|
172
|
+
```bash
|
|
173
|
+
# Create repo on GitHub first, then:
|
|
174
|
+
git init
|
|
175
|
+
git add .
|
|
176
|
+
git commit -m "Initial commit"
|
|
177
|
+
git remote add origin https://github.com/projectmd/node-monitor.git
|
|
178
|
+
git push -u origin main
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
3. **Verify npm Login:**
|
|
182
|
+
```bash
|
|
183
|
+
npm whoami
|
|
184
|
+
# Should show your npm username
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### After Publishing:
|
|
188
|
+
|
|
189
|
+
1. **Verify Publication:**
|
|
190
|
+
```bash
|
|
191
|
+
npm view @projectmd/node-monitor
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
2. **Test Installation:**
|
|
195
|
+
```bash
|
|
196
|
+
# In a test project
|
|
197
|
+
npm install @projectmd/node-monitor
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
3. **Update GitHub:**
|
|
201
|
+
```bash
|
|
202
|
+
git push
|
|
203
|
+
git tag v1.0.0
|
|
204
|
+
git push --tags
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## 🎯 Next Steps
|
|
210
|
+
|
|
211
|
+
### Immediate:
|
|
212
|
+
- [ ] Create GitHub repository (if not exists)
|
|
213
|
+
- [ ] Update repository URL in package.json (if needed)
|
|
214
|
+
- [ ] Login to npm: `npm login`
|
|
215
|
+
- [ ] Publish: `npm publish --access public`
|
|
216
|
+
|
|
217
|
+
### After Publishing:
|
|
218
|
+
- [ ] Verify package on npmjs.com
|
|
219
|
+
- [ ] Test installation in a new project
|
|
220
|
+
- [ ] Add npm badge to README.md
|
|
221
|
+
- [ ] Share with the community!
|
|
222
|
+
|
|
223
|
+
### Future Updates:
|
|
224
|
+
- [ ] Add tests (Jest is already configured)
|
|
225
|
+
- [ ] Set up CI/CD (GitHub Actions)
|
|
226
|
+
- [ ] Monitor package downloads
|
|
227
|
+
- [ ] Respond to issues and PRs
|
|
228
|
+
- [ ] Release updates with `npm version` and `npm publish`
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## 🆘 Need Help?
|
|
233
|
+
|
|
234
|
+
**Documentation:**
|
|
235
|
+
- See `PUBLISHING_GUIDE.md` for detailed publishing instructions
|
|
236
|
+
- See `GETTING_STARTED.md` for usage examples
|
|
237
|
+
- See `INSTALLATION.md` for installation options
|
|
238
|
+
|
|
239
|
+
**Validation:**
|
|
240
|
+
```bash
|
|
241
|
+
# Run pre-publish checks
|
|
242
|
+
node pre-publish-check.js
|
|
243
|
+
|
|
244
|
+
# Test package locally
|
|
245
|
+
npm pack
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
**Troubleshooting:**
|
|
249
|
+
- Not logged in? Run `npm login`
|
|
250
|
+
- Package name taken? Change name in package.json
|
|
251
|
+
- Version exists? Run `npm version patch`
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
## 🎉 Congratulations!
|
|
256
|
+
|
|
257
|
+
Your Node Monitor package is **production-ready** and **ready to publish**!
|
|
258
|
+
|
|
259
|
+
This is a comprehensive monitoring solution that will help Node.js developers monitor their applications with:
|
|
260
|
+
- ✅ Error tracking
|
|
261
|
+
- ✅ Health checks
|
|
262
|
+
- ✅ System monitoring
|
|
263
|
+
- ✅ Database monitoring
|
|
264
|
+
- ✅ Email & Slack notifications
|
|
265
|
+
- ✅ Beautiful web dashboard
|
|
266
|
+
|
|
267
|
+
**You've built something amazing! Now share it with the world! 🚀**
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
**Good luck with your npm package!** 🎊
|
|
272
|
+
|